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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing report of a specific record 1

Status
Not open for further replies.

cynaptic

Programmer
Sep 13, 2001
54
GB
I have a form that shows the details of contracts based on a relationship to a company name. I have a report that prints all the contracts in the system, I would like to have a uttom that will produce a report based on the company selected and the contracts shown for that company.

Any directions happily received.
 
If the company information is on the form before printing the report you could set up a button the would eqal the contractID. This is a sample of the coding.

If Forms![frmUtility].RecordsetClone.RecordCount = 0 Then
MsgBox "Enter Employee information before previewing invoice."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport "rptCertContract1", acPreview, , "[EmployeeID]=" & [EmployeeID]
End If
This will only print the Employee that is on the form prior to clicking the button. See if this helps.

:)
 
I have this same problem -- but...

my report is grouped in 3 tiers (not based on a query)
and i have a subreport in it

the button i created only brings up the subreport and the main report is blank

(not to mention this weird useless box comes up that i have to click 'ok' to)

what i want is to select the top tier group from a form and have that report show based on the selected group.

Private Sub Command8_Click()
Dim stDocName As String
Dim strWhere As String
stDocName = "New_Table"
strWhere = "[group_name]=" & Me!group_name
DoCmd.OpenReport "New Table", acPreview, , "[group_name]=" & [group_name]


End Sub
 
Thanks guys for your help - went to the site and came up with the following amendment of the wizards offering which seems to work ok.

Private Sub printreport_Click()
On Error GoTo Err_printreport_Click

Dim stDocName As String
Dim strWhere As String

stDocName = "Contracts"
strWhere = "[ContractID]=" & Me!ContractID
DoCmd.OpenReport stDocName, acNormal, , strWhere

Exit_printreport_Click:
Exit Sub

Err_printreport_Click:
MsgBox Err.Description
Resume Exit_printreport_Click

End Sub

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top