D
Dinger188
On a form, I have a combo box with a list of "Nature of Calls" and 2
additional combo boxes labeled Type of Fire and Cause of fire. If
"Fire" is
picked from the nature of call I would like to validate that the Type
of Fire
and Cause of Fire was completed. What I came up with works, but only
when
"Fire" is not picked. How do I do this correctly??
Here is what I have:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Const conBtns As Integer = vbOKOnly + vbCritical + vbDefaultButton2 +
vbApplicationModal
Dim intUserResponse As Integer
If IsNull(Me.Date) Then
Cancel = True
intUserResponse = MsgBox("Complete the INCIDENT DATE Field!", conBtns,
"STOP! Incomplete Field")
Me.Date.SetFocus
ElseIf IsNull(Me.Nature_of_Call) Then
Cancel = True
intUserResponse = MsgBox("Complete the NATURE OF CALL Field!", conBtns,
"STOP! Incomplete Field")
Me.Nature_of_Call.SetFocus
ElseIf IsNull(Me.Called_By) Then
Cancel = True
intUserResponse = MsgBox("Complete the CALLED BY Field!", conBtns,
"STOP!
Incomplete Field")
Me.Called_By.SetFocus
ElseIf (Me.Nature_of_Call) = "Fire" Then
ElseIf IsNull(Me.Type_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the TYPE OF FIRE Field!", conBtns,
"STOP!
Incomplete Field")
Me.Type_of_Fire.SetFocus
ElseIf IsNull(Me.Cause_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the CAUSE OF FIRE Field!", conBtns,
"STOP! Incomplete Field")
Me.Cause_of_Fire.SetFocus
End If
End Sub
additional combo boxes labeled Type of Fire and Cause of fire. If
"Fire" is
picked from the nature of call I would like to validate that the Type
of Fire
and Cause of Fire was completed. What I came up with works, but only
when
"Fire" is not picked. How do I do this correctly??
Here is what I have:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Const conBtns As Integer = vbOKOnly + vbCritical + vbDefaultButton2 +
vbApplicationModal
Dim intUserResponse As Integer
If IsNull(Me.Date) Then
Cancel = True
intUserResponse = MsgBox("Complete the INCIDENT DATE Field!", conBtns,
"STOP! Incomplete Field")
Me.Date.SetFocus
ElseIf IsNull(Me.Nature_of_Call) Then
Cancel = True
intUserResponse = MsgBox("Complete the NATURE OF CALL Field!", conBtns,
"STOP! Incomplete Field")
Me.Nature_of_Call.SetFocus
ElseIf IsNull(Me.Called_By) Then
Cancel = True
intUserResponse = MsgBox("Complete the CALLED BY Field!", conBtns,
"STOP!
Incomplete Field")
Me.Called_By.SetFocus
ElseIf (Me.Nature_of_Call) = "Fire" Then
ElseIf IsNull(Me.Type_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the TYPE OF FIRE Field!", conBtns,
"STOP!
Incomplete Field")
Me.Type_of_Fire.SetFocus
ElseIf IsNull(Me.Cause_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the CAUSE OF FIRE Field!", conBtns,
"STOP! Incomplete Field")
Me.Cause_of_Fire.SetFocus
End If
End Sub