If statement doesn't work

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have the following If statement on a button on a form in Access 2003. If
txtContact OR WhoReportedResults Is Null AND txtRptDate Is Not Null, then
give a message box. Otherwise, run the macro
mcrReportResultsForAnotherClient. Right now it runs the macro even if
txtContact or WhoReportedResults is null. THANKS!

Private Sub ReportResultsToAnotherClient_Click()
On Error GoTo Err_ReportResultsToAnotherClient_Click

If Not IsNull(Me.txtRptDate) And IsNull(Me.txtContact) Then
MsgBox "Who Reported Results and Contact must be entered."
DoCmd.GoToControl "EnterWhoReportedResults"

Else

If Not IsNull(Me.txtRptDate) And IsNull(Me.WhoReportedResults) Then
MsgBox "Who Reported Results and Contact must be entered."
DoCmd.GoToControl "EnterWhoReportedResults"
Else
DoCmd.RunMacro "mcrReportResultsForAnotherClient"
End If
End If

Exit_ReportResultsToAnotherClient_Click:
Exit Sub

Err_ReportResultsToAnotherClient_Click:
MsgBox Err.Description
Resume Exit_ReportResultsToAnotherClient_Click

End Sub
 
Mybe it's not null, its empty, so try this

If Not IsNull(Me.txtRptDate) And (IsNull(Me.txtContact) or Me.txtContact="")
Then
MsgBox "Who Reported Results and Contact must be entered."
DoCmd.GoToControl "EnterWhoReportedResults"

Else

If Not IsNull(Me.txtRptDate) And (IsNull(Me.WhoReportedResults) or
Me.WhoReportedResults="") Then
MsgBox "Who Reported Results and Contact must be entered."
DoCmd.GoToControl "EnterWhoReportedResults"
Else
DoCmd.RunMacro "mcrReportResultsForAnotherClient"
End If
End If
 
Back
Top