Hi again,
I have got (with your help) my userform working as intended, except for one minor problem:
Once the form is filled in the user should click..
"OK" and the data is written to the spreadsheet.
After this the form remains completed so in order to input the next set of data the second button needs to be pressed - "clear form"
This clears the form and allows the user to input the next data set, however the combobox options are multiplied. For example one of the comboboxes has 3 options, however on inputting the second set of data 6 options will appear, each option appearing twice. If the user then clears the form for the 3rd dataset then the combobox will have 9 options, again each option being repeated 3 times,.... and so on.
What do I need to do in order to get the combobox options to reset to the default of just 3 choices.
I attach my code below, and feel that the problem could lie in this section of code:
for info the rest of my code:
Option Explicit
Private Sub cboClientCategory_Change()
End Sub
Private Sub cboOutcome1_Change()
End Sub
Private Sub cboReferralType_Change()
End Sub
Private Sub CmdOk_Click()
ActiveWorkbook.Sheets("sheet2").Activate
Range("A10").Select
'to get down to the 1st empty row
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
'to put the client reference number into column A
ActiveCell.Offset(0, 0) = txtRef_No.Value
'in order to put the correct age group into column B
If OptUnder18 = True Then
ActiveCell.Offset(0, 1).Value = "Under 18"
ElseIf Opt1864 = True Then
ActiveCell.Offset(0, 1).Value = "18-64"
ElseIf Opt6574 = True Then
ActiveCell.Offset(0, 1).Value = "65-74"
ElseIf Opt75 = True Then
ActiveCell.Offset(0, 1).Value = "75+"
End If
'selected values from the comboboxes get put into column C to I on the same row
ActiveCell.Offset(0, 2) = cboClientCategory.Value
ActiveCell.Offset(0, 3) = cboReferralType.Value
ActiveCell.Offset(0, 4) = cboReferralSource.Value
ActiveCell.Offset(0, 5) = cboReferralReason.Value
ActiveCell.Offset(0, 6) = cboReferralReason2.Value
ActiveCell.Offset(0, 7) = cboReferralReason3.Value
'puts the selected ethnicity into column J
If OptWhitBrit = True Then
ActiveCell.Offset(0, 8).Value = "White British"
ElseIf OptWhitIrish = True Then
ActiveCell.Offset(0, 8).Value = "White Irish"
ElseIf OptWhitOther = True Then
ActiveCell.Offset(0, 8).Value = "White Other"
ElseIf OptMixedCaribbean = True Then
ActiveCell.Offset(0, 8).Value = "Mixed Caribbean"
ElseIf OptMixedAfrican = True Then
ActiveCell.Offset(0, 8).Value = "Mixed African"
ElseIf OptMixedAsian = True Then
ActiveCell.Offset(0, 8).Value = "Mixed Asian"
ElseIf OptMixedOther = True Then
ActiveCell.Offset(0, 8).Value = "Mixed Other"
ElseIf OptAsianIndian = True Then
ActiveCell.Offset(0, 8).Value = "Asian Indian"
ElseIf OptAsianPakistani = True Then
ActiveCell.Offset(0, 8).Value = "Asian Pakistani"
ElseIf OptAsianOther = True Then
ActiveCell.Offset(0, 8).Value = "Asian Other"
ElseIf OptBlackCaribbean = True Then
ActiveCell.Offset(0, 8).Value = "Black Caribbean"
ElseIf OptBlackAfrican = True Then
ActiveCell.Offset(0, 8).Value = "Black African"
ElseIf OptBlackOther = True Then
ActiveCell.Offset(0, 8).Value = "Black Other"
ElseIf OptChinese = True Then
ActiveCell.Offset(0, 8).Value = "Chinese"
ElseIf OptChineseOther = True Then
ActiveCell.Offset(0, 8).Value = "Other ethnicity"
ElseIf OptNotStated = True Then
ActiveCell.Offset(0, 8).Value = "Not Stated"
End If
'puts the FACS eligibility into column K of the sanme row
If OptLow = True Then
ActiveCell.Offset(0, 9).Value = "Low"
End If
'selected values from the comboboxes get put into column L to O on the same row
ActiveCell.Offset(0, 10) = cboOutcome1.Value
ActiveCell.Offset(0, 11) = cboOutcome2.Value
ActiveCell.Offset(0, 12) = cboOutcome3.Value
'records whether the person is receiving services from teh department
If OptYes = True Then
ActiveCell.Offset(0, 13) = "Yes"
ElseIf OptNo = True Then
ActiveCell.Offset(0, 13) = "No"
End If
'records the current date in column "P"
ActiveCell.Offset(0, 14) = Date
'Readies the active cell for inputting of the next form
Range("A10").Select
ActiveCell.Offset(1, 0).Select
End Sub
Private Sub CmdClear_Click()
Call UserForm_Initialize
End Sub
'Closes the form (and protects the range where data is automatically input)
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub Frame3_Click()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Initialize()
txtRef_No.Value = ""
With cboClientCategory
.AddItem "Older People (Not EMI) [Aged 65-74]"
.AddItem "Older People (Not EMI) [Aged 75+]"
.AddItem "Physical Disability/Sensory Impairment [Aged 18-64]"
.AddItem "Learning Disability [Aged 18-64]"
.AddItem "Mental Health / EMI [Aged 18-64]"
.AddItem "Mental Health / EMI [Aged 65-74]"
.AddItem "Mental Health / EMI [Aged 75+]"
.AddItem "Substance Misuse [Aged 18-64]"
.AddItem "Other Vulnerable People [Aged 18-64]"
End With
cboClientCategory.Value = ""
With cboReferralType
.AddItem "New Client"
.AddItem "1st Contact of year for an existing client"
.AddItem "Repeat (i.e. Subsequent contact within the year)"
End With
cboReferralType.Value = ""
With cboReferralSource
.AddItem "Southport DGH (HFHS)"
.AddItem "Aintree Hospital"
.AddItem "Other Hospital"
.AddItem "Not Known"
End With
cboReferralSource.Value = ""
With cboReferralReason
.AddItem "Shopping"
.AddItem "Laundry"
.AddItem "Housework"
End With
cboReferralReason.Value = ""
With cboReferralReason2
.AddItem "Shopping"
.AddItem "Laundry"
.AddItem "Housework"
End With
cboReferralReason2.Value = ""
With cboReferralReason3
.AddItem "Shopping"
.AddItem "Laundry"
.AddItem "Housework"
End With
cboReferralReason3.Value = ""
With cboOutcome1
.AddItem "Referral to other agency/organisation"
.AddItem "Provision of advice and information"
.AddItem "Safety assessment"
.AddItem "HFHS to be provided"
End With
cboOutcome1.Value = ""
With cboOutcome2
.AddItem "Referral to other agency/organisation"
.AddItem "Provision of advice and information"
.AddItem "Safety assessment"
.AddItem "HFHS to be provided"
End With
cboOutcome2.Value = ""
With cboOutcome3
.AddItem "Referral to other agency/organisation"
.AddItem "Provision of advice and information"
.AddItem "Safety assessment"
.AddItem "HFHS to be provided"
End With
cboOutcome3.Value = ""
OptLow = True
OptUnder18 = False
Opt1864 = False
Opt6574 = False
Opt75 = False
OptWhiteBrit = False
OptWhiteIrish = False
OptWhiteOther = False
OptMixedCaribbean = False
OptMixedAfrican = False
OptMixedAsian = False
OptMixedOther = False
OptAsianIndian = False
OptAsianPakistani = False
OptAsianOther = False
OptBlackCaribbean = False
OptBlackAfrican = False
OptBlackOther = False
OptChinese = False
OptChineseOther = False
OptNotStated = False
End Sub
Display More
Any help with this is greatly appreciated...
Thanks
Damian