Multiple IF/OR statements

  • Thread starter Thread starter Allan Murphy
  • Start date Start date
A

Allan Murphy

Robert

Change Public Function ChkNull() to sub ChkNull() and change exit function
to End Sub. A Function is used to return a result to the where the function
was called, it this case you have not determined a result.


Change your if statement to
If (IsNull(frmActive.JobOrder)) Or (IsNull(frmActive.SSN)) Or
(IsNull(frmActive.BillRate)) Then

What is the purpose of the "frmMissingData" ?

I would code the above on the Got focus event of the control to run the
process as
If (IsNull(frmActive.JobOrder)) Or (IsNull(frmActive.SSN)) Or
(IsNull(frmActive.BillRate)) Then
DoCmd.CancelEvent
MsgBox "Job Order or SSN or Bill Rate is missing. Please correct
and re-run the process"
DoCmd.GoToControl "Job Order"
End If
 
What’s the best way to use multiple If /OR statements? I have the following
code to bring up a form if any of the fields are blank:

Public Function ChkNull()
'Check for blank/invalid fields in: JO#,SSN, Bill Rate.
Dim frmActive As Form
Set frmActive = Screen.ActiveForm

If (IsNull(frmActive.JobOrder)) Or IF (IsNull(frmActive.SSN)) Or if
(IsNull(frmActive.BillRate)) Then
MsgBox "You have missing Data. Please correct and re-run the process"
DoCmd.OpenForm "frmMissingData"
End If
Exit Function
 
Back
Top