PDA

View Full Version : Force a combo box choice?



mud2
11-27-2006, 03:17 PM
The complicated I can (usually) do, but the simple??
I have two combo boxes. I want to FORCE the user to choose something from each combo box...othgerwise I get a Null Error. Help me with this and I'll submit an ELEGENT way of using combo boxes!

asingh
11-27-2006, 06:36 PM
Are you going to put a sumbit command button on the form..where the 2 combos reside.....?

Else how will the event fire that checks if combos have been selected.....?

mud2
11-27-2006, 10:15 PM
Under the button that continues after the combo boxes (shouldhave) been checked:
Test if the Combo box values are true or false. (False means not null)
If False
Do whatever...
Else
MsgBox("Choose!")
End If

Works like a charm!

Saurabhk
11-28-2006, 04:37 PM
Hi mud2,

Try the following code


Private Sub Command5_Click()
If IsNull(Combo0) Then
MsgBox "PLEASE SELECT A"
Exit Sub
End If
If IsNull(Combo2) Then
MsgBox "PLEASE SELECT B"
Else
SEL1 = Me.Combo0.Value
SEL2 = Me.Combo2.Value
Text6.SetFocus
Text6.Text = SEL1 & " " & SEL2
Me.Combo0.Value = Null
Me.Combo2.Value = Null
End If
End Sub

Hope it helps

CFDM
12-05-2006, 02:02 PM
If IsNull(me.txtfield)=true or me.txtfield = "" then
MsgBox("Please select a value")
Exit Sub
End if
me.txtfield.setfocus

CORYWP
12-06-2006, 12:08 PM
I would use a toggle for a submit button and enable it when both combo box's are not null.