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

Print Access Report

Status
Not open for further replies.

whjwilson

Technical User
Jan 20, 2006
23
0
0
US
I am working on a database, and have a report built that I am trying to print using a Forms Page. I added a Command button to the page and have it set up to print, but when I print it prints all records. Is there a way to set it up to only print the current record using a Command Button? Thanks.
 
Yes, in the code of the On_Click event of that command button there should be an OpenReport statement.

You can enter a where condition like this:

DoCmd.OpenReport "yourReport", acViewNormal, ,"ID = " & Forms!yourForm!yourIdentifyingValueField

You can look in Access Help for more specifics on on to put a where clause onto your report as it opens.
 
I have input the above code in, and it is still printing all records. I may be doing something wrong with the "ID = " above. Form I am trying to print is titled Full_Pass_Print so I modified what you have above to:

DoCmd.OpenReport "Full_Pass_Print", acViewNormal, ,"ID = " & Forms!Full_Pass_Print!yourIdentifyingValueField

what should I be using as the IdentifyingValueField and for "ID = "

any Help would be appreciated.
 
what is the criteria you are trying to return? If you only want the current record, that information should be stored on form Full_Pass_Print somewhere. what's the name of the control that's holding the id of the current record and what's the name of the field in the table that the criteria needs to be verified against?

DoCmd.OpenReport "Full_Pass_Print", acViewNormal, ,"put name of table field here = " & Forms!Full_Pass_Print!name of control on form that has value to compare to field in table

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
lespaul

thanks for the help, I kept putting in the wrong field name when I was trying it earlier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top