Printing a Report of The Current Record of Data Entry Screen

notoca

New Member
Joined
Sep 8, 2003
Messages
37
Hi

I have a data entry form for an invoice. Most of the information is part of the form table. However, some onformation like Customer name comes from the customer table. I have a button on the invoice form that is supposed to produce a report based upon the current record. Unfortunately because the report requires additional information from other tables such as the customers address (from the customers table) this has to be done via a query. So, the froblem. How do I pass the current record parameter to the query in order to produce the report soley for the current record. The query has all records in it and somehow I need to filter it from the Invoice form when the button is pressed to report on the current record.

The code I have so far is:

Private Sub Preview_Invoice_Invoice_Request_Click()
On Error GoTo Err_Preview_Invoice_Invoice_Request_Click

Me.Refresh

Dim strReportName As String
Dim strCriteria As String

If Invoice_Total_GST_Incl < 51 Then
strReportName = "rpt_Invoice_Details"
Else
strReportName = "rpt_Invoice_Request"
End If

strCriteria = "[Invoice_No]='" & Me![Invoice_No] & "'"
DoCmd.OpenReport strReportName, acViewPreview, strCriteria

Exit_Preview_Invoice_Invoice_Request_Click:
Exit Sub

Err_Preview_Invoice_Invoice_Request_Click:
MsgBox Err.Description
Resume Exit_Preview_Invoice_Invoice_Request_Click

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Re: Printing a Report of The Current Record of Data Entry Sc

Presumably your query has an InvoiceNo field (or whatever the ID for Invoices is in your system).
Open your query in design view. In the Criteria row for InvoiceNo, type
[Forms]![frmInvoices]![InvoiceNo]
You may need to adjust form and control names to suit.

Denis
 
Upvote 0
Re: Printing a Report of The Current Record of Data Entry Sc

Thanks Denis, That worked a treat.
 
Upvote 0

Forum statistics

Threads
1,221,607
Messages
6,160,787
Members
451,671
Latest member
kkeller10

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top