object required message/error

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top