print single record (yes again)

btappan

Registered User.
Local time
Today, 15:03
Joined
Feb 24, 2007
Messages
40
I have searched and found countless threads for how to print a single record being being viewed on a form to report but none of them seem to be working for me, it still keeps printing ALL records. I have attached a simple sample database of what i'm working with, it has a table, a form, and the report set up to print on a 4x6 label. I need my print button on the form to be able to be clicked and print only the current record in the form. Also i need either a text box next to the print button to specify how many copies, or the dialog box for the printer where i can specify a qty. Anyone got any suggestions?
 

Attachments

Last edited:
I have searched and found countless threads for how to print a single record being being viewed on a form to report but none of them seem to be working for me, it still keeps printing ALL records. I have attached a simple sample database of what i'm working with, it has a table, a form, and the report set up to print on a 4x6 label. I need my print button on the form to be able to be clicked and print only the current record in the form. Also i need either a text box next to the print button to specify how many copies, or the dialog box for the printer where i can specify a qty. Anyone got any suggestions?


Private Sub CmdPrintPass_Click()
Dim strDocName As String
Dim strLinkCriteria As String

DoCmd.RunCommand acCmdSaveRecord
strDocName = "YourReportName"
strLinkCriteria = "YourPrimaryKey = Forms![YourFormName]![YourControlName]"
DoCmd.OpenReport strDocName, acViewPreview, , strLinkCriteria
End Sub

This will open a preview of the current record in the report you specified in the code. You can then right mouse click and choose Print. From there you can set up the printing in any manner you like.
 
i just tried it am i get nothing at all with this. no errors, no print, nothing.
 
If you still need someone to look at your db you need to zip it and send it again. I downloaded it and unzipped it and it came up with a .accdb extension, whatever that is! Tried renaming it with a .mdb extension but it came up as "unrecognized format."
 
Your report should be based on a query... In that query the current record ID from your form should be the criteria. As for the multiple copies look into this.... DoCmd.PrintOut [printrange],[pagefrom],[pageto],[printquality],[copies],[collatecopies]
You should be able to put an unbound textbox on the form to insert your number of copies.. Then replace the [printquantity] with that textbox.
PS... you might also post your db in .mdb format for those who do not have Access 07 :)
 
try the newly attached database here:
its going to print preview now but all the fields are blank?
 

Attachments

try the newly attached database here:
its going to print preview now but all the fields are blank?

Fixed. Now it will preview the current record. You had the PK control named wrong. You had named it as the command button and it should have been named ID (the name of the control in the form).
 

Attachments

Thanks So Much

You're welcome. Now you can tweak it using CEH's code and see if you can get it to print from within the program instead of right-clicking in preview mode.
 

Users who are viewing this thread

Back
Top Bottom