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

Using current form data in report selection query 2

Status
Not open for further replies.

KarenMO

Technical User
Jul 14, 2005
8
US
Hello - I have created a very simple (flat) database that has just four user fields and some command buttons for viewing and printing reports. The users will only ever need to print these small summary reports based on the job number of the current record in the form. The report is based on a query that, if run from the report tab, will prompt the user for the job number. I would like the user to be able to view or print the report from the (command button on the) form without having to enter the selection criteria, because the job number will already be displayed on the form. I have done this successful in a previous database and have tried to duplicate the coding scenario in that database, but without success. Thanks in advance for any help! - Karen
 
In the query criteria, instead of having the job nunber criteria equal to a prompt, set it to something like:
Code:
=[Forms]![YourFormNameHere].[YourJobNumberFieldNameHere]
Then when the query runs it will pick the currently displayed job number up right off the form.

[pc2]
 
Karen
You can include a WHERE clause in the DoCmd line that opens the report.

For example...
DoCmd.OpenReport "YourReportName", acViewPreview, , "[JobNumber] = '" & Forms!YourFormName!YourFormField & "'"

Tom
 
WOW, mp9 and Tom - that was SUPERFAST - the "ink" has barely dried on my post! Both solutions are useful and this is all I need to finish up the database and send it to the client. THANKS SO MUCH! - Karen :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top