Refresh Report before printing?

tim1982

Registered User.
Local time
Yesterday, 22:32
Joined
Feb 18, 2009
Messages
21
Hello,

From a Form where I input information to be printed, I always have to re-open the form in order to print (otherwise, it doesn't print the most recent information added.)

Is there a way to get my VBA print command to create a report to print with the most recent refreshed information before printing so I don't have to re-open the form first?

Thanks in advance.

Here's my code so far
--------------------------------------------------
Private Sub Command38_Click()

DoCmd.OpenReport "PurchaseOrder", PrintOut, , _
"[OrderID]=Forms![Orders].[OrderID]"
--------------------------------------------------
 
Just add this line to the click event before the open of the report:

If Me.Dirty Then Me.Dirty = False

which will save the record on the form if it has been modified and then the report should pick up the new values.
 
Woohoo!

Thank you, sir. It appears to be working. (This will save me some serious time when printing file after file. I used to have to re-open each dialog box to make sure I was printing the newest updates.)

Tim
 
You could also save the record this way before printing:

DoCmd.RunCommand acCmdSaveRecord
 
You could also save the record this way before printing:

DoCmd.RunCommand acCmdSaveRecord
Yes, that is another option, however using this will force a save regardless whereas

If Me.Dirty Then Me.Dirty = False

will only force a save if there is something to save. And, depending on if you save things like "last date updated" etc. it can be important.
 
You could also save the record this way before printing:

DoCmd.RunCommand acCmdSaveRecord

I find it best to check to se3e if it needs saved or you might get an error message.

I use:
Code:
If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom