How do I break out of an "If" statement?

kawi6rr

Registered User.
Local time
Today, 05:11
Joined
Jun 29, 2010
Messages
28
I have two if statements below, is anything returns null on the first if statement I want it to stop and proceed to the form. But as is both if statements run and I end up on the nutrition screen.


If IsNull(Me.Catheter.Form!Combo81) Or IsNull(Me.Catheter.Form!Combo58) Then
MsgBox "You have missing fields in Catheter"
Me.Catheter.Visible = True
End If
If IsNull(Me.Nutrition.Form!Combo29) Then
MsgBox "You have empty fields in Nutrition"
Me.Nutrition.Visible = True
End If

Any help is appreciated, thanks!
 
I have two if statements below, is anything returns null on the first if statement I want it to stop and proceed to the form. But as is both if statements run and I end up on the nutrition screen.


If IsNull(Me.Catheter.Form!Combo81) Or IsNull(Me.Catheter.Form!Combo58) Then
MsgBox "You have missing fields in Catheter"
Me.Catheter.Visible = True
End If
If IsNull(Me.Nutrition.Form!Combo29) Then
MsgBox "You have empty fields in Nutrition"
Me.Nutrition.Visible = True
End If

Any help is appreciated, thanks!
Not sure if this is what you want:
Code:
If IsNull(Me.Catheter.Form!Combo81) Or IsNull(Me.Catheter.Form!Combo58) Then
MsgBox "You have missing fields in Catheter"
Me.Catheter.Visible = True
ElseIf IsNull(Me.Nutrition.Form!Combo29) Then
MsgBox "You have empty fields in Nutrition"
Me.Nutrition.Visible = True
End If
 
You can use

Exit sub

After the visible code.
 
See the part in red
Code:
If IsNull(Me.Catheter.Form!Combo81) Or IsNull(Me.Catheter.Form!Combo58) Then
    MsgBox "You have missing fields in Catheter"
    Me.Catheter.Visible = True
[COLOR=Red]ElseIf [/COLOR]IsNull(Me.Nutrition.Form!Combo29) Then
    MsgBox "You have empty fields in Nutrition"
    Me.Nutrition.Visible = True
End If
 
Well, this has to be a record. Three replies at the same time. :)
 
Perhaps protect the second if statement inside an else block?

Code:
If IsNull(Me.Catheter.Form!Combo81) Or IsNull(Me.Catheter.Form!Combo58) Then
   MsgBox "You have missing fields in Catheter"
   Me.Catheter.Visible = True
[B][COLOR=Red]ElseIf[/COLOR][/B] IsNull(Me.Nutrition.Form!Combo29) Then
   MsgBox "You have empty fields in Nutrition"
   Me.Nutrition.Visible = True
End If

But what if nothing evaluates true... or or or...

Perhaps this will be a start at least.
 
Michael wanted to join the party too but caught the late train ;)
 

Users who are viewing this thread

Back
Top Bottom