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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in query expression printing record 1

Status
Not open for further replies.

TBOB

Technical User
Jun 22, 2002
65
US
When I try to print a single record from a form I get the following error message:

Syntax Error (Missing Operator)in query expression '(3600siteid = Forms!3600!3600siteid).

I'm using the following code to print a record:

Dim strDOCNAME As String
Dim strFILTER As String

strDOCNAME = "3600AllInfo"
strFILTER = "3600siteid = Forms!3600!3600siteid"

DoCmd.OpenReport strDOCNAME, acViewNormal, , strFILTER

I've used this same code on other forms in this database and had success with it. Can anyone help me figure out why this one is different?

Thanks,

Tony
 
In the report named "3600AllSites" you have either a table or a query supplying the records(Record Source property). The filter is trying to be executed against this Record Source. It is looking for a field/column called "3600siteid". Is there one?

Try putting square brackets around it.
i.e. strFILTER = "[3600siteid] = Forms!3600![3600siteid]"

The other possibility is that it is not recognizing the control from the form. Check out that the control is being identified correctly. I have also square bracketed the control in your expression.

Give these a try and get back with me with the results.



Bob Scriver
 
Bob,

The brackets fixed it. Thanks alot. Just out of curiosity, why did this one require brackets and the same code in other instances didn't?

Thanks again,

Tony
 
I suspect that it is because the names of your form, table, and control all start with 3600 and it gets a little confused.

My Philosophy: There are times when it pays not to ask the reason why but just to succumb to the absolutes. If you bracket the items ACCESS never gets it wrong.

Good luck and thanks for the star. Bob Scriver
 
Not actually knowing how you used the string "^^2^^" I would believe that the carot character is not allowed in the manner that you are using it.

Need more info about the statement that caused this problem. Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top