Validating fields......

  • Thread starter Thread starter Dean Knox
  • Start date Start date
D

Dean Knox

Hi, Can anybody help me, I have a selection of comboboxes
on a form. I want to make sure that each one has an item
selected before enabling the 'next' button to take them
onto another page (frame). i.e they must fill the form
out completley before continuing. I am writing this in
VBA, if no-one can help could they point me to a code
reference website that can help.

Thanks

Dean
 
Dean,

As an example, lets have three combo boxes (ComboBox1,
ComboBox2, ComboBox3) and a Next button (CommandButton1)

Here is the code you need to get it working:

Private Sub UserForm_Initialize()
Dim v As Variant

v = Array(1, 2, 3, 4, 5)
ComboBox1.List = v
ComboBox2.List = v
ComboBox3.List = v
Me.CommandButton1.Enabled = False
End Sub

Private Sub ComboBox1_Change()
Check_NextEnable
End Sub

Private Sub ComboBox2_Change()
Check_NextEnable
End Sub

Private Sub ComboBox3_Change()
Check_NextEnable
End Sub

Sub Check_NextEnable()
Me.CommandButton1.Enabled = _
Me.ComboBox1.ListIndex >= 0 And _
Me.ComboBox2.ListIndex >= 0 And _
Me.ComboBox3.ListIndex >= 0
End Sub

If you need more details, let me know

Cheers,
Dave.
 
Back
Top