I posted this originally in the wrong forum. Sorry about that.
I'm using Access 97. I'm trying to open my report with the current record on my form. I do this with a button on my form.
When I click the button I get this error message:
Syntax error ( missing operator ) in query expression '([Building Name] = Gilbert Hall )'
Here's my code:
Private Sub State_Fire_Marshal_button_Click()
On Error GoTo Err_Command187_Click
Dim stDocName As String
Dim stWhere As String
stDocName = "EHS Reports"
stWhere = "[EHS Form] = " & Me.[Building Name]
DoCmd.OpenReport stDocName, acPreview, , stWhere
Exit_Command187_Click:
Exit Sub
Err_Command187_Click:
MsgBox Err.Description
Resume Exit_Command187_Click
End Sub
The right side of this line seems to be working fine:
stWhere = "[Building Name] = " & Me.[Building Name]
[Building Name] = Gilbert Hall
When I remove the second comma before stWhere in the last line of the code:
DoCmd.OpenReport stDocName, acPreview, stWhere
the report does open but to the first record not the current record on the form.
I think I'm doing something wrong with the left side?
Any suggestions?
If you need more info, let me know
Thanx
Gustavson
I'm using Access 97. I'm trying to open my report with the current record on my form. I do this with a button on my form.
When I click the button I get this error message:
Syntax error ( missing operator ) in query expression '([Building Name] = Gilbert Hall )'
Here's my code:
Private Sub State_Fire_Marshal_button_Click()
On Error GoTo Err_Command187_Click
Dim stDocName As String
Dim stWhere As String
stDocName = "EHS Reports"
stWhere = "[EHS Form] = " & Me.[Building Name]
DoCmd.OpenReport stDocName, acPreview, , stWhere
Exit_Command187_Click:
Exit Sub
Err_Command187_Click:
MsgBox Err.Description
Resume Exit_Command187_Click
End Sub
The right side of this line seems to be working fine:
stWhere = "[Building Name] = " & Me.[Building Name]
[Building Name] = Gilbert Hall
When I remove the second comma before stWhere in the last line of the code:
DoCmd.OpenReport stDocName, acPreview, stWhere
the report does open but to the first record not the current record on the form.
I think I'm doing something wrong with the left side?
Any suggestions?
If you need more info, let me know
Thanx
Gustavson