Printing one record

Ringers

Registered User.
Local time
Today, 11:53
Joined
Mar 4, 2003
Messages
54
I have created a report using the wizard called service report. I have added a button to my form(MainForm). I want it to print the particular record that i am currently looking at. But when you click the button it prints every record.

I have never done this before so i have no idea how to fix this. Any help would be great. Ta:D
 
Ringers,

Put this in the OnClick event of your command button:

Code:
DoCmd.OpenReport "YourReport",,,"[KeyField] = " & Me.KeyField

You'll have to change the name of your report and your key
field. If your key is a string, surround it with single-quotes.

Wayne
 
Ta got it
 
Before you print the report, you need to force Access to save the current record. Otherwise, if the record is new the report won't pick it up since it has not yet been saved or if it was changed, the changes have not yet been saved. So, in front of the OpenReport, add:

DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom