If statement doesn't work

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top