All the records are being printed from the form...Not only the one

eme126

Registered User.
Local time
Today, 08:21
Joined
Jun 2, 2006
Messages
45
:confused: Hi,
I have a form that loads from a menu option. The form has two subforms. All the specs are divided in groups within the forms and subforms. The forms depend on 3 queries that have all the tables correctly gathered. So, every title has a little print button next to it if the user wants to only print that group; if he or she wants to print the entire form, there is a button for that at the end of the form. I am currently having problems with the groups printing. Given that they mostly depend on a separate table and not the general one, every time I click any of the little buttons, I end up printing all the records in that table. I would like to be able to print only the info seen at the moment on the form.:(

Here is the code of one of the groups:

Private Sub Print_OperatingMechanism_Click()
On Error GoTo Err_Print_OperatingMechanism_Click

Dim stDocName As String

stDocName = "OperatingMechanism"
DoCmd.OpenReport stDocName, acViewPreview

Exit_Print_OperatingMechanism_Click:
Exit Sub

Err_Print_OperatingMechanism_Click:
MsgBox Err.Description
Resume Exit_Print_OperatingMechanism_Click

End Sub

Thanks in advance...
 
The OpenReport Method takes additional parameters. One of them is a where clause without the where that allows you to control the records that are printed.
 
So, should I just modify the Where clause?
 
For some reason this is still not printing only what it's shown on the screen. Should I do some kind of query definition? I was just wondering if I was missing something because OperatingMechanism is a table that is linked to the main table. So it is just printing all the records in the Operating Mechanism without taking into account the own it is displaying.

CODE:

Private Sub Print_OperatingMechanism_Click()
On Error GoTo Err_Print_OperatingMechanism_Click

'Dim stReportName As String

'stReportName = "OperatingMechanism"
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[OperatingMechanism]=" & OperatingMechanism.Operating_Mechanism

Exit_Print_OperatingMechanism_Click:
Exit Sub

Err_Print_OperatingMechanism_Click:
MsgBox Err.Description
Resume Exit_Print_OperatingMechanism_Click
 

Users who are viewing this thread

Back
Top Bottom