Limit OpenReport to Current Record

Michael's Knight

Registered User.
Local time
Today, 14:38
Joined
Mar 17, 2014
Messages
27
Windows 7 OS
Access 2013
I posted this question in the Macro discussion area, but perhaps it is more appropriate here:

I have a report that gives me an overview of my records, and i have built a report that gives me the desired details. I have created a button that will open the details report. When i open the overview report i get all the records in a list, when i click the button in any of the given records it will give me all the records details.
How can i limit the results to just the record i am clicking the button form (Current Record)?
 
You need to set your Criteria to such, i.e.

If your field is numeric...
Code:
DoCmd.OpenReport "YourReport", acViewPreview, , "[FieldInReport]=" & Me![ControlOnForm]

If your field is text…
Code:
DoCmd.OpenReport "YourReport", acViewPreview, , "[FieldInReport]='" & Me![ControlOnForm] & "'"
 
It is a text field,
I get a "compile error Expect end of statement" window, and its highlighting my command in the square brackets.

Code:
DoCmd.OpenReport "BookDetailsReport", acViewPreview, ,"[BookTitle]='" & Me! [Command20] & "'"
 
Last edited:
That is Command20? A button? You can't use a Command Button is criteria. What is the name of the field that holds the Book Title?
 
The field in the table is called BookTitle
As is apparent I know absolutely nill about coding
 
I'm sorry,
Command20 is the command button i created to execute this action/open the report
 
That would be the problem. Where is says Command20 in the line you need to change that, in the line in Post 3, to a field on your Form that holds the Book Title.
 
It still wasn't working when i would place the Field name there either, so i re-made the field in the report and now it works!
Thank you so much!
 

Users who are viewing this thread

Back
Top Bottom