Test 2 combos for data

BarryMK

4 strings are enough
Local time
Today, 13:32
Joined
Oct 15, 2002
Messages
1,350
I'm using the code below to prompt users to fill in two combos before moving to the next tab page on my form.
It works when both combos are empty but if I update the first combo and press the LOST button again it fires the setfocus event. Is this a "null" problem?

Code:
Private Sub cmdLost_Click()
    Dim Msg As String
    If IsNull(Me.cmbBreed) Or (Me.cmbColour) Then
    MsgBox "Fill in Breed and Colour Now." & vbCrLf & "Then click the LOST button again.", vbInformation, "Required fields!"
    DoCmd.CancelEvent
   Else
     Me.Mutt.SetFocus
    End If
End Sub
 
Doh!

Worked it out! Just needed another IsNull before the second combo.

Code:
Private Sub cmdLost_Click()
    Dim Msg As String
    If IsNull(Me.cmbBreed) Or IsNull(Me.cmbColour) Then
    MsgBox "Fill in Breed and Colour Now." & vbCrLf & "Then click the LOST button again.", vbInformation, "Required fields!"
    DoCmd.CancelEvent
   Else
     Me.Mutt.SetFocus
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom