Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Criteria to run Reports 1

Status
Not open for further replies.

ZeoGel

Technical User
May 13, 2003
28
US
I am tring to create a report with multiple criterias from a form. I have tried this code but keep getting a " missing operator error" with can someone show me where iam going wrong?

Private Sub Command7_Click()
On Error GoTo Err_Command7_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[Class]=" & Me![Class] & " AND [Manager]= " & Me![Manager]


stDocName = "rptExamsavg"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_Command7_Click:
Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
 
If Class and/or Manager are text fields you'll have to wrap the criteria values in double quotes (or Chr(34) which is probably easier).

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
I have tried it and get the same error missing operator.

But thanks for the suggestion.
 
Could you show what you tried that didn't work?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
here is what i did

stLinkCriteria = ("[Class]=" & Me![Class] & " AND [Manager]= " & Me![Manager])
 
Ah, I see. I meant double quotes, something more like:
Code:
stLinkCriteria = "[Class]=" & Chr(34) & Me![Class] & Chr(34) & " AND [Manager]= " & Chr(34) & Me![Manager] & Chr(34)
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Sweet!!!!!! You Rock! Thank you for the help it has only been a week i have been trying to get this to work.


Very Appreciative of your Assistance
Ron.
 
Glad I could help, thanks for the star [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Oops, sorry. I typed that on autopilot! [blush]

Glad I could help anyway [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top