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

Newbie question 1

Status
Not open for further replies.

jivetrky

MIS
Jun 16, 2006
38
US
I am new to access. I'm sure this is easy to do. I have created a data entry form and a report. I want to have a button on this form to dynamically build a report for this data entry form and display it. At this point, when I want to print the form, I have to go through all the reports to find the one I want.

Your help would be greatly appreciated.
 
As in
DoCmd.OpenReport "Name of Report", acViewPreview
Or had you something fancier in mind?
 
I would like it to only display the report for that record instead of all the records.
 
This is a fairly usual question. The answer is to use the Where argument:

[tt]DoCmd.OpenReport "Name of Report", acViewPreview, , "ID=" & Me.Id[/tt]

Where ID is the name of a unique field (numeric in the above example) in the query that the report is based on, and the ID in Me.ID is the name of a control on the current form that contains the relevant data.

Alernatively, edit the query on which the report is based and add:
[tt]=Forms![Form Name]!ID[/tt]
to the criteria line for the relevant field. Once again, is the name of a control on the current form that contains the relevant data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top