What am I missing

outlaw318

Registered User.
Local time
Today, 08:24
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]"

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

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click

End Sub
 
Its telling me there is a data type mismatch in the criteria expression.
 
If BuildingNo is text, you need to enclose it in quotes.

stLinkCriteria = "[buildingno]= '" & Me.BuildingNo & "'"
 

Users who are viewing this thread

Back
Top Bottom