Current Record Report?

Hydra427

Registered User.
Local time
Today, 04:21
Joined
Mar 9, 2012
Messages
40
I have a form that I use to enter diecast cars into my database. At the end of the form I have a text box "Label Printed" That shows if a label has been printed for that current record on the form. I am adding a print button to the form and want it to print the report "Box Label Report" for the current record on the form. Can anyone give me some help on the code needed to print the report based on the current record.
 
OK, I think I figured out a way to make this work, it may be clunky but it does the job. I would prefer if the report never opened and just closed if someone knows a better solution let me know.

Code:
Private Sub Command14_Click()
DoCmd.OpenReport "Labels Table1", acViewPreview, acHidden, "[ID]=" & Me.ID
DoCmd.PrintOut , , , , 1
DoCmd.Close acReport, "Labels Table1", acSaveYes
Me.[Text Label] = "Yes"
End Sub
 
I tried all three suggestions but now it prints the record on the form and then prints the form with all records. So instead of only getting the one record I am getting a page with the record in question and then the form prints with all 10 records.
 
You would delete the PrintOut and Close lines.
 
You would delete the PrintOut and Close lines.
Is that with the acNormal, or the way I have code written now. I want the button to print the report when I push it and not have it open the report so I can hit the print button on the report page when it opens.
 
With the acNormal. That line prints the report with the selected record, making the next 2 lines unnecessary. In fact the PrintOut line is printing out the form, which is why you're getting all records.
 
With the acNormal. That line prints the report with the selected record, making the next 2 lines unnecessary. In fact the PrintOut line is printing out the form, which is why you're getting all records.
Thank you, can you explain the acHidden and what its function is as well. I tried reading online about it but to no avail.
 
You don't need it with acNormal, the report won't open visibly anyway. You'd use acHidden if you were opening the report for printing or exporting but didn't want the user to see it open/close (it would probably be so fast it would just look like flicker). I sometimes use it when I want to export a report filtered with the wherecondition:

DoCmd.OpenReport...
DoCmd.OutputTo...
DoCmd.Close
 

Users who are viewing this thread

Back
Top Bottom