Simple code for 'OnLoad' event to print a report (1 Viewer)

nicktheblue

Registered User.
Local time
Today, 22:51
Joined
Sep 15, 2001
Messages
18
Hello forum,
Can anyone give me a few pointers on the following...
I want to print a report from a command button on a form, the number of which is taken from the 'OrderID' field on that form. I could be quite wrong, but I am assuming that if I attach a piece of code to the 'OnLoad' event on the form I can Bookmark the 'OrderID' and use it to referance the correct report for the print command. Can anyone tell me how to do this, or will it just not work? My limited knowledge has reached its end! Thanks in advance,

Nick
 

chrismcbride

Registered User.
Local time
Today, 22:51
Joined
Sep 7, 2000
Messages
301
If you use the On Load event, then you will always be referencing the first record in the form's RecordSource (table or query). I don't think this is what you want.
The usual solution would be to put the command to open the report in the Click event of your button and , assuming you want to print the current record, the reference the current record using the Me object.


DoCmd.OpenReport "rptWhatever", acPreview,,"id = " & Me.id
HTH
Chris
 

nicktheblue

Registered User.
Local time
Today, 22:51
Joined
Sep 15, 2001
Messages
18
Thanks Chris,
I think this is just what I need.
Much appreciated,

Nick
 

Users who are viewing this thread

Top Bottom