Earlier in this thread we worked out a bunch of validation code for my Run Sheet form. After using the Run Sheet in the real world for a while, it has been determined that I need to add to the validation rules. What I need to do is have all validation rules ignored if the combobox "RunAssessment" equals "Aborted". Is there a way to do this?
For reference, here is the current code used on the submit button that contains all of the validation rules:
Code:
Private Sub EventCombo_AfterUpdate()ScenarioCombo.Requery
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
'BOA nominal or off nominal
If (Me.BOARunResults = "Nominal" Or Me.BOARunResults = "Off Nominal") Then 'start BOA checks
'BOA Operator
If IsNull(Me.BOAOperator) Then
MsgBox "Please select a BOA Operator", vbInformation, "Atention!"
Cancel = True
Me.BOAOperator.SetFocus
Exit Sub
End If
'BOATracksExpected
If IsNull(Me.BOATracksExpected) Then
MsgBox "Please enter the number of Tracks Expected for BOA", vbInformation, "Atention!"
Cancel = True
Me.BOATracksExpected.SetFocus
Exit Sub
End If
'BOATracksReceived
If IsNull(Me.BOATracksReceived) Then
MsgBox "Please enter the number of Tracks Received for BOA", vbInformation, "Atention!"
Cancel = True
Me.BOATracksReceived.SetFocus
Exit Sub
End If
'BOATracksProcessed
If IsNull(Me.BOATracksProcessed) Then
MsgBox "Please enter the number of Tracks Processed by BOA", vbInformation, "Atention!"
Cancel = True
Me.BOATracksProcessed.SetFocus
Exit Sub
End If
'BOATracksReleased
If IsNull(Me.BOATracksReleased) Then
MsgBox "Please enter the number of Tracks Released by BOA", vbInformation, "Atention!"
Cancel = True
Me.BOATracksReleased.SetFocus
Exit Sub
End If
'BOAComms
If IsNull(Me.BOAComms) Then
MsgBox "Please select the comms type that was used for BOA", vbInformation, "Atention!"
Cancel = True
Me.BOAComms.SetFocus
Exit Sub
End If
End If ' end of BOA Checks
If (Me.SBIRSRunResults = "Nominal" Or Me.SBIRSRunResults = "Off Nominal") Then 'start SBIRS checks
'SBIRSSIMOperator
If IsNull(Me.SBIRSSIMOperator) Then
MsgBox "Please select a SBIRS SIM Controller", vbInformation, "Atention!"
Cancel = True
Me.SBIRSSIMOperator.SetFocus
Exit Sub
End If
'SBIRSTracksExpected
If IsNull(Me.SBIRSTracksExpected) Then
MsgBox "Please enter the number of Tracks Expected for SBIRS", vbInformation, "Atention!"
Cancel = True
Me.SBIRSTracksExpected.SetFocus
Exit Sub
End If
'SBIRSTracksReceived
If IsNull(Me.SBIRSTracksReceived) Then
MsgBox "Please enter the number of Tracks Received for SBIRS", vbInformation, "Atention!"
Cancel = True
Me.SBIRSTracksReceived.SetFocus
Exit Sub
End If
'SBIRSTracksProcessed
If IsNull(Me.SBIRSTracksProcessed) Then
MsgBox "Please enter the number of Tracks Processed for SBIRS", vbInformation, "Atention!"
Cancel = True
Me.SBIRSTracksProcessed.SetFocus
Exit Sub
End If
'SBIRSTracksReleased
If IsNull(Me.SBIRSTracksReleased) Then
MsgBox "Please enter the number of Tracks Released for SBIRS", vbInformation, "Atention!"
Cancel = True
Me.SBIRSTracksReleased.SetFocus
Exit Sub
End If
'SBIRSUnscripted
If IsNull(Me.SBIRSUnscripted) Then
MsgBox "Please enter the number of Unscripted Boosters for SBIRS", vbInformation, "Atention!"
Cancel = True
Me.SBIRSUnscripted.SetFocus
Exit Sub
End If
'SBIRSComms
If IsNull(Me.SBIRSComms) Then
MsgBox "Please select the comms type that was used for SBIRS", vbInformation, "Atention!"
Cancel = True
Me.SBIRSComms.SetFocus
Exit Sub
End If
'SBIRSWorkstation
If Len(Nz(Me.SBIRSWorkstation1, "") & Nz(Me.SBIRSWorkstation2, "") & Nz(Me.SBIRSWorkstation3, "") & Nz(Me.SBIRSWorkstation4, "") & Nz(Me.SBIRSWorkstation5, "")) = 0 Then
MsgBox "Please select an Operator for the SBIRS Workstation that was used", vbInformation, "Atention!"
Cancel = True
Me.SBIRSWorkstation1.SetFocus
Exit Sub
End If
End If 'end of SBIRS checks
End Sub
Private Sub SubmitRSButton_Click()
On Error GoTo Err_Handler
Me.Dirty = False
If MsgBox("Record has been submitted! Do you want to go to a new record?", vbYesNo, "New record?") = vbYes Then
DoCmd.GoToRecord , , acNewRec
End If
Exit_Here:
Exit Sub
Err_Handler:
If Err.Number = 3021 Then
'ignore or message
Else
MsgBox Err.Number & " " & Err.Description
End If
Resume Exit_Here
End Sub