Hi all!
Need a little help with a problem concerning multiple IF functions in a form. I have a button that on click will print a report if certain fields in the form have data in them. If not, a msgbox pops up to let the user know that data must be filled and then sets focus on whichever field needs data in the form. There are many IF statements, and they all work fine until I get to a certain one then the remaining IF does not continue.
Here is some code:
If IsNull([Alert]) Then
MsgBox "An alert time is required." _
, vbCritical, "Data Required"
Me.Text591.SetFocus
Exit Sub
Else
If IsNull([Enroute]) Then
MsgBox "An enroute time is required." & vbNewLine & "If you do not have an enroute time, enter four(4) dashes (-)." _
, vbCritical, "Data Required"
Me.Text593.SetFocus
Exit Sub
Else
If IsNull([On Scene]) Then
MsgBox "An on scene time is required." & vbNewLine & "If you do not have an on scene time, enter four(4) dashes (-)." _
, vbCritical, "Data Required"
Me.Text595.SetFocus
Exit Sub
Else
If IsNull([Available]) Then
MsgBox "An available time is required." _
, vbCritical, "Data Required"
Me.Text597.SetFocus
Exit Sub
Else
If IsNull([Event Address/Location]) Then
MsgBox "An event address/location is required." _
, vbCritical, "Data Required"
Me.Text599.SetFocus
Exit Sub
Else
The next IF argument will bring up the msgbox when there is no data, thats great. However, when the user fills in the field and continues with the button click to print the report, the button does nothing.
Here is the next IF, the one with the problem:
If IsNull([Combo608]) Then
If IsNull([Combo620]) Then
MsgBox "You must select either a planned event or an emergency event." _
, vbCritical, "Information"
Me.Combo608.SetFocus
Exit Sub
Else
Any ideas on how to get it to work, to continue with the remaining IF arguments after this one (there are several more)?
Or are there a better way to code this and not have the many IF arguments?
Need a little help with a problem concerning multiple IF functions in a form. I have a button that on click will print a report if certain fields in the form have data in them. If not, a msgbox pops up to let the user know that data must be filled and then sets focus on whichever field needs data in the form. There are many IF statements, and they all work fine until I get to a certain one then the remaining IF does not continue.
Here is some code:
If IsNull([Alert]) Then
MsgBox "An alert time is required." _
, vbCritical, "Data Required"
Me.Text591.SetFocus
Exit Sub
Else
If IsNull([Enroute]) Then
MsgBox "An enroute time is required." & vbNewLine & "If you do not have an enroute time, enter four(4) dashes (-)." _
, vbCritical, "Data Required"
Me.Text593.SetFocus
Exit Sub
Else
If IsNull([On Scene]) Then
MsgBox "An on scene time is required." & vbNewLine & "If you do not have an on scene time, enter four(4) dashes (-)." _
, vbCritical, "Data Required"
Me.Text595.SetFocus
Exit Sub
Else
If IsNull([Available]) Then
MsgBox "An available time is required." _
, vbCritical, "Data Required"
Me.Text597.SetFocus
Exit Sub
Else
If IsNull([Event Address/Location]) Then
MsgBox "An event address/location is required." _
, vbCritical, "Data Required"
Me.Text599.SetFocus
Exit Sub
Else
The next IF argument will bring up the msgbox when there is no data, thats great. However, when the user fills in the field and continues with the button click to print the report, the button does nothing.
Here is the next IF, the one with the problem:
If IsNull([Combo608]) Then
If IsNull([Combo620]) Then
MsgBox "You must select either a planned event or an emergency event." _
, vbCritical, "Information"
Me.Combo608.SetFocus
Exit Sub
Else
Any ideas on how to get it to work, to continue with the remaining IF arguments after this one (there are several more)?
Or are there a better way to code this and not have the many IF arguments?