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

open a report from a form 1

Status
Not open for further replies.

pthakar

Programmer
Feb 28, 2003
38
US
Hello all
Could ny one pl. tell me how to open a report from a form by clicking a button for the same record.the user wnats to hjave the printout for the selected record by pressing a print button.
Tahnks in advance
 
Does your form have a unique number like an AutoNumber?

If yes, then create a Query for the report and for the criteria pass the value as [Forms]![FORMNAME]![FIELDNAME]
Then on the button that will open the Report you must refresh by me.refresh

If no, then create a field with an AutoNumber unique to the record

Hope this helps
 
the code to open the report is:

DoCmd.OpenReport "YourReportName", acViewPreview

leave the acViewPreview off the end to print the report without previewing.

To only print the particular record, you will need to query your data for this particular record. In your report you will need to set the Record Source to your query.

You can use SQL or simply create the query through Access.

When you create your query be sure you include the key field in your criteria so it will pull the particular record.

For example, if the key field on your form is ID, then in the criteria section of your query under the ID field you will need to enter something like this:

Forms!YourFormName!YourFieldName.value

YourFormName refers to the name of the form your pulling the report from.

YourFieldName refers to the name of the field as it appears on the form.

hope this helps you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top