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
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