Printing a 'label'

Nic

Registered User.
Local time
Today, 11:00
Joined
Jan 15, 2012
Messages
47
Hi,
Iv got a form with various data on it. The data comes from a table.
I wish to print the detils on my form onto a label (10cmx12cm) as it appears on my form. I understand the best way to do this is via a report.
So, i have created my report from the same table that my form gets its data from. I have laid my report out (visually) in the style i wish to appear on my printed label. Then i have added a cmd button to my form, which carries out the 'print report' code.
However, this code sends all the records in my table to the printer, where as i only want to print the current record. Any suggetsions?
This is my current print code behind the cmd button on my form:

Private Sub PrintLabel_Click()
On Error GoTo Err_PrintLabel_Click
Dim stDocName As String
stDocName = "PalletLabel"
DoCmd.OpenReport stDocName, acNormal
Exit_PrintLabel_Click:
Exit Sub
Err_PrintLabel_Click:
MsgBox Err.Description
Resume Exit_PrintLabel_Click

End Sub

Suggestions greatly welcome,

many thanks,
 
Suggestions greatly welcome,

Without actually seeing it, I can only make a general suggestion. If you have a report based on a query, and the query references the form that is open and contains the command button that launches the report, then you should be all set.

HTH
 
Use the where argument on the command.

I just googled for 'print report for current record access' for the syntax
and found this answer

Use the OpenReport's Where condition to specify your record. For example, the following code placed behind a command button on the form would use the RunID control on the form to restrict the Report to only one record.

Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere

HTH

Hi,
Iv got a form with various data on it. The data comes from a table.
I wish to print the detils on my form onto a label (10cmx12cm) as it appears on my form. I understand the best way to do this is via a report.
So, i have created my report from the same table that my form gets its data from. I have laid my report out (visually) in the style i wish to appear on my printed label. Then i have added a cmd button to my form, which carries out the 'print report' code.
However, this code sends all the records in my table to the printer, where as i only want to print the current record. Any suggetsions?
This is my current print code behind the cmd button on my form:

Private Sub PrintLabel_Click()
On Error GoTo Err_PrintLabel_Click
Dim stDocName As String
stDocName = "PalletLabel"
DoCmd.OpenReport stDocName, acNormal
Exit_PrintLabel_Click:
Exit Sub
Err_PrintLabel_Click:
MsgBox Err.Description
Resume Exit_PrintLabel_Click

End Sub

Suggestions greatly welcome,

many thanks,
 

Users who are viewing this thread

Back
Top Bottom