Alan Jackson
Alan Jackson

Reputation: 7

I need my report to only show the current record

I asked a question yesterday which was answered and now works. I need to extend the code to modify the report slightly. I have a form called Specification with a field called "SpecID". I have added a button to this form to open a specific report but obviously it opens the report to include all the records in the Specification Form. I want the report to only show one record which would be referenced by the SpecID field and which would be the currently open record in the form. I have tried various ideas based on some of the answers on here but none seem to have worked.

Currently my code is DoCmd.OpenReport Me![Report Name], acViewPreview

I need better brains than mine to tell me what I need to add to this to get the report to only show data from the currently open form which will be referenced by the SpecID field. Im sure it will be simple and thanks in advance.

Upvotes: 0

Views: 647

Answers (1)

Gustav
Gustav

Reputation: 55856

Extend your code to include a filter expression:

DoCmd.OpenReport Me![Report Name], acViewPreview, , "[SpecID]=" & Me!SpecID.Value & ""

Upvotes: 1

Related Questions