Hi. I have the following code below where after user makes a selection the code will check if the other necessary fields are filled in or not. Then, a message will be displayed if any or both required fields are not filled. I am able to do this with only one necessary field but unable to duplicate when there are two mandatory fields needed for a given value. I'm new to access so any help will be much appreciated.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strAField As String
Dim strBField As String
strAField = ""
strBField = ""
If Nz(Me.FStatusID) = 3 And Nz(Me.BoxLoc) = "" And Nz(Me.DestDate) = "" Then
strAField = "BoxLoc"
strBField = "DestDate"
ElseIf Nz(Me.FStatusID) = 5 And Nz(Me.BoxLoc) = "" Then
strAField = "BoxLoc"
ElseIf Nz(Me.FStatusID) = 6 And Nz(Me.BoxLoc) = "" And Nz(Me.DestDate) = "" Then
strAField = "BoxLoc"
strBField = "DestDate"
ElseIf Nz(Me.FStatusID) = 7 And Nz(Me.BoxLoc) = "" Then
strBField = "DestDate"
End If
If strAField <> "" And strBField <> "" Then
MsgBox "Please complete required " & strAField & "."
MsgBox "Please complete required " & strBField & "."
Cancel = True
End If
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strAField As String
Dim strBField As String
strAField = ""
strBField = ""
If Nz(Me.FStatusID) = 3 And Nz(Me.BoxLoc) = "" And Nz(Me.DestDate) = "" Then
strAField = "BoxLoc"
strBField = "DestDate"
ElseIf Nz(Me.FStatusID) = 5 And Nz(Me.BoxLoc) = "" Then
strAField = "BoxLoc"
ElseIf Nz(Me.FStatusID) = 6 And Nz(Me.BoxLoc) = "" And Nz(Me.DestDate) = "" Then
strAField = "BoxLoc"
strBField = "DestDate"
ElseIf Nz(Me.FStatusID) = 7 And Nz(Me.BoxLoc) = "" Then
strBField = "DestDate"
End If
If strAField <> "" And strBField <> "" Then
MsgBox "Please complete required " & strAField & "."
MsgBox "Please complete required " & strBField & "."
Cancel = True
End If
End Sub