object required message/error

G

Guest

can anyone help? why am i getting this message when i use this code:

Private Sub PrintAudit_Click()
On Error GoTo Err_PrintAudit_Click
Dim stDocName As String
Dim Response As Integer
stDocName = "Audit Report"
If Me.Earliest.Value Is Not Null And Me.Latest.Value Is Not Null Then
DoCmd.OpenReport stDocName, acNormal, , "[Date of Audit] Between
Forms![Print Report].Earliest and Forms![Print Report].Latest"
Else
Response = MsgBox("You must enter the range of dates the Audit Report
spans", vbCritical + vbOKOnly)
End If
Exit_PrintAudit_Click:
Exit Sub

Err_PrintAudit_Click:
MsgBox Err.description
Resume Exit_PrintAudit_Click

End Sub

-ted
 
G

George Nicholson

You can't test for Null that way.
Actually, you can't test for anything that way: "..Is Not.." is a *very*
tempting comparison, but it doesn't fly in VB :)
Try:
If Not IsNull(Me.Earliest.Value) And Not IsNull(Me.Latest.Value)
Then

HTH,
--
George Nicholson

Remove 'Junk' from return address.


Ted said:
can anyone help? why am i getting this message when i use this code:

Private Sub PrintAudit_Click()
On Error GoTo Err_PrintAudit_Click
Dim stDocName As String
Dim Response As Integer
stDocName = "Audit Report"
If Me.Earliest.Value Is Not Null And Me.Latest.Value Is Not Null Then
DoCmd.OpenReport stDocName, acNormal, , "[Date of Audit] Between
Forms![Print Report].Earliest and Forms![Print Report].Latest"
Else
Response = MsgBox("You must enter the range of dates the Audit Report
spans", vbCritical + vbOKOnly)
End If
Exit_PrintAudit_Click:
Exit Sub

Err_PrintAudit_Click:
MsgBox Err.description
Resume Exit_PrintAudit_Click

End Sub

-ted
 

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