Report Preview Erroring Out Instead of Opening (1 Viewer)

quest4

Registered User.
Local time
Today, 03:35
Joined
Oct 12, 2004
Messages
246
Good morning, I have a cmdButton and it is supposed to open a report on the current user being displayed in the form. Instead, I get an error, Data type mismatch in criteria expression. Here is the procedure:
Private Sub Preview_Click()
On Error GoTo Err_Preview_Click
Dim stDocName As String
stDocName = "RptFactSheet"
DoCmd.OpenReport "RptFactSheet", acPreview, , "[AddressID] = " & [AddressID]
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
MsgBox Err.Description
Resume Exit_Preview_Click
End Sub
I can not see what I am doing wrong here, any suggestions? Thank you in advance for any help.:confused:
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:35
Joined
Aug 11, 2003
Messages
11,695
Is your addressID a number field??
If it is a text field you must encluse it with quotes, like so:
"[AddressID] = '" & [AddressID] & "'"
If it were a date field, use # around your fields.

If this is not the problem your problem lays in the query that is used in the report or a calculation that is beeing done in the report.

Oh... If/when you post code please use [ code ] and [/ code ] (without the spaces) around your code, this preserves the indentations....
 

quest4

Registered User.
Local time
Today, 03:35
Joined
Oct 12, 2004
Messages
246
Thanks a lot that did the trick.
 

Users who are viewing this thread

Top Bottom