Combo Boxes

  • Thread starter Thread starter bgomezesthela
  • Start date Start date
B

bgomezesthela

I have no idea of what i am doing wrong but.. I have 2 comboboxes (combobox1
and ComboBox2) I have this so far:

Private Sub ComboBox1_Change()
ComboBox1.AddItem "New User"
ComboBox1.AddItem "Change User"
End Sub

Private Sub ComboBox2_Change()
ComboBox2.AddItem "Audit/Auditors (External Internal)"
ComboBox2.AddItem "Ben Admin/BA Director"
ComboBox2.AddItem "Ben Admin/BA Supervisor"
ComboBox2.AddItem "Ben Admin/Ben Calc/Death/Enrollment Team"
ComboBox2.AddItem "Ben Admin / Disability"
ComboBox2.AddItem "Ben Admin / Drop / DRO"
ComboBox2.AddItem "Ben Admin/Employer Services"
ComboBox2.AddItem "Ben Admin/Health Admin"
ComboBox2.AddItem "Ben Admin/Imaging/Records Distrib"
ComboBox2.AddItem "Ben Admin/Special Projects"
ComboBox2.AddItem "IS/Administration"
ComboBox2.AddItem "IS/Business Analyst"
ComboBox2.AddItem "IS/Data Analyst"
ComboBox2.AddItem "IS/IT Director"
ComboBox2.AddItem "Finance Admin / CFO"
ComboBox2.AddItem "Finance Admin/Financial Administration"
ComboBox2.AddItem "Finance Admin/Financial Reporting"
ComboBox2.AddItem "Finance Admin / Payroll"
ComboBox2.AddItem "Legal/DRO/Disability"
ComboBox2.AddItem "Legal/General"
ComboBox2.AddItem "Member Services/Call Center-Reception"
ComboBox2.AddItem "Member Services / Counseling"
ComboBox2.AddItem "Member Services / Director"
End Sub

When I try my form by choosing one of the options on any of the two boxes
all the entries duplicate automatically... Why is doing this?
Can someone help me please..
 
There is a group called microsoft.public.word.vba.userforms that might
be a more appropriate place to post this.

I think your issue might be that you set all the options using the
change event (ie every time you make a selection and change the value
it will trigger the event and rebuild the list). It might be better to
have a macro that draws a form (with userform1.Show) after defining
the two combo boxes.
 
Hi bgo:

When you work with UserForms, you sent up the .AddItem method when the
UserForm is initiated. When you click on any blank area of a UserForm you end
up with the Initialize Event:
'------------------------------------------------
Private Sub UserForm_Initialize()
On Error Resume Next
With ComboBox2
.AddItem "Audit/Auditors (External Internal)"
.AddItem "Ben Admin/BA Director"
.AddItem "Ben Admin/BA Supervisor"
.AddItem "Ben Admin/Ben Calc/Death/Enrollment Team"
.AddItem "Ben Admin / Disability"
.AddItem "Ben Admin / Drop / DRO"
.AddItem "Ben Admin/Employer Services"
.AddItem "Ben Admin/Health Admin"
.AddItem "Ben Admin/Imaging/Records Distrib"
.AddItem "Ben Admin/Special Projects"
.AddItem "IS/Administration"
.AddItem "IS/Business Analyst"
.AddItem "IS/Data Analyst"
.AddItem "IS/IT Director"
.AddItem "Finance Admin / CFO"
.AddItem "Finance Admin/Financial Administration"
.AddItem "Finance Admin/Financial Reporting"
.AddItem "Finance Admin / Payroll"
.AddItem "Legal/DRO/Disability"
.AddItem "Legal/General"
.AddItem "Member Services/Call Center-Reception"
.AddItem "Member Services / Counseling"
.AddItem "Member Services / Director"
End With

etc etc etc

End Sub
'------------------------------------------------

I rarely use the Change Event, because if you place code like:
'------------------------------------------------
Private Sub ComboBox1_Change()
[TextBox1] = ComboBox1.Value
End Sub
'------------------------------------------------
The textbox will now refresh until the end user clicks on the form, which is
annoying. Instead, use the Click Event:
'------------------------------------------------
Private Sub ComboBox1_Click()
[TextBox1] = ComboBox1.Value
End Sub
'------------------------------------------------
To get around this problem...

Regards,
Al

Now
 
Back
Top