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

How to Print Current Record Only

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
For the life of me I can not figure this out; how to get on the current record to print. ie, on button click get report with the current records data to print. I am a novice and have found one example which I could not get to work using the RUNID control (what the heck is that)
My hat is off to you db pros, I am a doc with many years of schooling; you folks amaze me!
 
Set up code like this in the OnClick event of your command button:
Code:
Dim strCriteria As String
strCriteria = "[tblYourTable]![Table_field]=[Forms]![frmYourForm]![Form_field]"
DoCmd.OpenReport "rptReport", acNormal, , strCriteria
Hope this helps!!
 
Thanks, I hope this will work. Can you help me identify the variables which need to be inserted in the code? Also; how can I go to report preview rather than straight to print? Thanks so much!
 
The code should probably reference the primary key of your table. You just need something to uniquely identify the record that you want the report to print. Just substitute your field names into the statement.

strCriteria = "[uniquetablefield] = " & me![formfieldname]

If this field is a text field then use this instead:

strCriteria = "[tablefield] = "' & me![formfieldname] & "'"

docmd.openreport "reportnamehere", acviewpreview,,strCriteria Maq B-)
<insert witty signature here>
 
This seems to work, however... the preview opens for a split second, then disappears. If I click the button many times the preview on the report will open. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top