Docmd.OpenReport Where Clause Problem

Shaft

Registered User.
Local time
Today, 13:02
Joined
May 25, 2005
Messages
51
Can somebody please tell me what is wrong with the statement below. I've got a button on a tabular form and when I press the button I want it to open the report for the record that is selected a that time. Data Input is the report and report is the name of the form. The error I'm geting is "Microsoft Access cannot find the field '|' reffered to in your expression" bt I can't see that character anywhere in my expression.

Please Help.

DoCmd.OpenReport stDocName, acPreview, , [Data Input].ID = Report.ID
 
The Access Help Files entry for OpenReport tells you exactly what you are doing wrong.
 
Cheers for the help should have found that myself really. It working with no errors now but it's returning all the records not just the one that is selected.

Any help would be much appreciated.

This is my statement now:-

stDocName = "Data Input"
DoCmd.OpenReport stDocName, acPreview, , [ID] = Forms![Report]![ID]
 
Shaft said:
Cheers for the help should have found that myself really. It working with no errors now but it's returning all the records not just the one that is selected.

stDocName = "Data Input"
DoCmd.OpenReport stDocName, acPreview, , [ID] = Forms![Report]![ID]

The help files stated that the criteria should be a String.

Code:
[ID] = Forms![Report]![ID]
This is not a String.

Code:
"[ID] = " & Forms("Report").ID

That is a string. ;)
 
Sorry it's me being thick again I knew I shouldn't have gone the pub at lunchtime. I was looking at the OpenReport Action not Method.

Thanks for the help sorry to bother you.
 

Users who are viewing this thread

Back
Top Bottom