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

Problem trying to print specific report from a form

Status
Not open for further replies.

Dophia

Technical User
Jul 26, 2004
263
CA
I have an invoice form which uses a control button to print the invoice based on the invoice number. But, I can't get the specific invoice to print. The "Preview/Print" control button's OnClick event is as follows:

Private Sub Inv_Click()
On Error GoTo Err_Inv_Click

Dim stDocName As String

stDocName = "RptInvoice"

DoCmd.OpenReport stDocName, acPreview, , _
"[tblInvoice_Invoice_No] = '" & Forms!FrmInvoice!Invoice_No _
& "'"


Exit_Inv_Click:
Exit Sub

Err_Inv_Click:
MsgBox Err.Description
Resume Exit_Inv_Click

End Sub

I have used the same code to print other specific reports, but for some reason, I can't get this one to work. This form is based on tables and not on a query. Could that be the problem?

The report is based on a Query:

SELECT tblInvoice_details.Invoice_No AS tblInvoice_Invoice_No, tblInvoice.Invoice_Date, tblInvoice.People_ID AS tblInvoice_People_ID, tblPeople.People_ID AS tblPeople_People_ID, tblPeople.Last_Name, tblPeople.First_Name, tblPeople.Spouse_CommonLaw_Last_Name, tblPeople.Spouse_CommonLaw_First_Name, tblPeople.House_No, tblPeople.Street_Address, tblPeople.Street_Suffix, tblPeople.[N/S/E/W], tblPeople.Apartment_No, tblPeople.PO_Box, tblPeople.City, tblPeople.Province, tblPeople.Postal_Code, tblPeople.Home_Phone_No, tblPeople.Cell_Phone_No, tblPeople.Work_Phone_No
FROM tblPeople INNER JOIN ((tblFees INNER JOIN ((tblInvoice INNER JOIN QryInvoice_details_subtotals ON tblInvoice.Invoice_No = QryInvoice_details_subtotals.Invoice_No) INNER JOIN QryInvoice_details ON tblInvoice.Invoice_No = QryInvoice_details.Invoice_No) ON tblFees.Item_No = QryInvoice_details.Item_No) INNER JOIN tblInvoice_details ON (tblInvoice.Invoice_No = tblInvoice_details.Invoice_No) AND (tblFees.Item_No = tblInvoice_details.Item_No)) ON tblPeople.People_ID = tblInvoice.People_ID;


Any suggestions?
Thanks, Sophia
 
Please disregard this question. I found a way to make it work by changing the expression, as follows:

Private Sub Inv_Click()
On Error GoTo Err_Inv_Click

Dim strWhere, strReportName As String
strWhere = "[Invoice_No] = " & Me.Invoice_No

strReportName = "RptInvoice"
DoCmd.OpenReport strReportName, acPreview, , strWhere
Exit_Inv_Click:
Exit Sub

Err_Inv_Click:
MsgBox Err.Description
Resume Exit_Inv_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top