Open Report Code

outlaw318

Registered User.
Local time
Today, 01:08
Joined
Oct 2, 2003
Messages
15
After reading almost everywhere on this site to get rid of macros I am trying to write code for the simple stuff. Can anyone tell me what I am missing? I am trying to open the Building Info report based on the field "BuildingNo".

Private Sub Command43_Click()
On Error GoTo Err_Command43_Click

Dim stDocName As String
stLinkCriteria = "[buildingno]=" & Me.BuildingNo

stDocName = "BuildingInfo"
DoCmd.OpenReport stDocName, , , stLinkCriteria

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click

End Sub

I keep getting a data type mismatch in criteria selection.
 
Are you sure that you're not misspelling the field (in your report) that you're filtering on?
 
A data type mismatch indicates that building number is a text field, not a number. If so, it would need to be something like this:

stLinkCriteria = "[buildingno]= '" & Me.BuildingNo & "'"
 
I am trying to use this code to open a form. It seems to be working but instead of opening the report it prints it. What am I doing wrong?
 

Users who are viewing this thread

Back
Top Bottom