Printing the current record from the report

sho ryu ken

Registered User.
Local time
Today, 19:11
Joined
Aug 12, 2005
Messages
15
Hi, I have set up my form so that there is a print button, looking a little like this :

http://www.sdkjewellers.co.uk/printreport.JPG

But how do I get it so the print button prints the report for only the currently selected record?

Code for the print button is simply:



Private Sub Command33_Click()
On Error GoTo Err_Command33_Click

Dim stDocName As String

stDocName = "Labels Customers"
DoCmd.OpenReport stDocName, acNormal

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click



End Sub


Thanks
 
Base the report on a query and set the criteria in the query to:

=Forms!formname!controlname

where formname is the name of your form and controlname the name of the control with the primary key.
 
Use the Where clause of the OpenReport method, many examples have been posted here
 
Hello, thanks.

I have most of it working now, but when I hit the button I get a blank report, I think it's my query criteria which is wrong?

[forms]![form1]![cmb1]
I have that as the critera (form1 is the name of my form, cmb1 is the name of the combo box where they select the report number)

So why do you have to use a combo box anyway? Isn't there a variable stored in memory containing the number of the current active record which you can use?
 
sho ryu ken said:
Hello, thanks.

I have most of it working now, but when I hit the button I get a blank report, I think it's my query criteria which is wrong?

[forms]![form1]![cmb1]
I have that as the critera (form1 is the name of my form, cmb1 is the name of the combo box where they select the report number)

So why do you have to use a combo box anyway? Isn't there a variable stored in memory containing the number of the current active record which you can use?

First the form has to be open. Second, You don't have to use a combo, but its usually better. But no, there is no variable storing the active record info. Check to make sure that you are correctly using the bound column of the combo.
 
Well first of all your combo is named combo6, not CMB1, the control name is on the Other tab of the properties dialog. Second, in your query the controlname shows just 1. Finally, since you already have the Mailing List Id as a control, then just use that in your query.
 

Users who are viewing this thread

Back
Top Bottom