Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-16-2001, 11:44 PM   #1
nicktheblue
Junior Member
 
Join Date: Sep 2001
Location: England
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
nicktheblue
Simple code for 'OnLoad' event to print a report

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

nicktheblue is offline   Reply With Quote
Old 10-17-2001, 08:52 AM   #2
chrismcbride
Senior Member
 
Join Date: Sep 2000
Location: Ottawa, Ontario, Canada
Posts: 301
Thanks: 0
Thanked 1 Time in 1 Post
chrismcbride is on a distinguished road
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
chrismcbride is offline   Reply With Quote
Old 10-19-2001, 05:19 AM   #3
nicktheblue
Junior Member
 
Join Date: Sep 2001
Location: England
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
nicktheblue
Thanks Chris,
I think this is just what I need.
Much appreciated,

Nick

nicktheblue is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 11:51 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World