Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

oop94

Programmer
Jun 14, 2005
31
US
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...
 
I have never done a filter. I am very new at this. So, may you help me witht that?
 
something like this.

Dim stDocName As String
Dim strWhere as string
strGroupValue as string
strGroupValue = someMeansToReturnTheGroupYouWantToPrint
stDocName = "OperatingMechanism"
strWhere = "[yourGroupFieldName] = '" & strGroupValue & "'"
'disregard the single quotes if not as string value
docmd.OpenReport stDocName,acViewPreview,,strWhere
 
Should this code work (because it isn't really):

Private Sub Print_OperatingMechanism_Click()
On Error GoTo Err_Print_OperatingMechanism_Click

'Dim stReportName As String

'stReportName = "OperatingMechanism"
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "Operating Mechanism = " & OperatingMechanism

Exit_Print_OperatingMechanism_Click:
Exit Sub

Err_Print_OperatingMechanism_Click:
MsgBox Err.Description
Resume Exit_Print_OperatingMechanism_Click

End Sub

Please help me:-(
 
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[Operating Mechanism] = '" & OperatingMechanism & "'"

If Operating Mechanism is defined as numeric then get rid of the single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I did not fix it. But thank you for trying.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top