J
Jani
I need to have three fields filled in prior to running a macro w/queries and
then opening a form. The code I have is below and it works if at least one of
the fields is filled but if all three fields are empty, it sometimes works
and the cursor ends up in the Date field or sometimes I get a runtime error
that the focus can't move to Combo100. I'm sure my code could be lot
cleaner. Any help would be much appreciated! Thanks!
Private Sub Box236_Click()
If IsNull(Me!Region) Then
MsgBox "You must select a Region"
Me!Region.SetFocus
Cancel = True
End If
If IsNull(Me!Combo100) Then
MsgBox "You must select a Location"
Me!Combo100.SetFocus
Cancel = True
End If
If IsNull(Me!cmbRepMonth) Then
MsgBox "You must select a Date"
Me.cmbRepMonth.SetFocus
Else
DoCmd.RunMacro "macMonthlyDataProcess"
DoCmd.Maximize
End If
End Sub
then opening a form. The code I have is below and it works if at least one of
the fields is filled but if all three fields are empty, it sometimes works
and the cursor ends up in the Date field or sometimes I get a runtime error
that the focus can't move to Combo100. I'm sure my code could be lot
cleaner. Any help would be much appreciated! Thanks!
Private Sub Box236_Click()
If IsNull(Me!Region) Then
MsgBox "You must select a Region"
Me!Region.SetFocus
Cancel = True
End If
If IsNull(Me!Combo100) Then
MsgBox "You must select a Location"
Me!Combo100.SetFocus
Cancel = True
End If
If IsNull(Me!cmbRepMonth) Then
MsgBox "You must select a Date"
Me.cmbRepMonth.SetFocus
Else
DoCmd.RunMacro "macMonthlyDataProcess"
DoCmd.Maximize
End If
End Sub