G
George
Hi I need help
I have a report that populates from a query and I want the report to open on
the current record basede on the form and subform current fields.
My code is as follows
Private Sub btnPrintReport_Click()
On Error GoTo Err_btnPrintReport_Click
Dim stDocName As String
stDocName = "Agreement"
Dim strWhere As String
If Me.Dirty Then 'save first
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select the record to print."
Else
strWhere = "[Customers_CustomerID] = " & Forms![ProjectsAll]![Customers
Subform].Form![Customers_CustomerID]
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
End If
Exit_btnPrintReport_Click:
Exit Sub
Err_btnPrintReport_Click:
MsgBox Err.Description
Resume Exit_btnPrintReport_Click
End Sub
Any help greatly appreciated
Thanks
I have a report that populates from a query and I want the report to open on
the current record basede on the form and subform current fields.
My code is as follows
Private Sub btnPrintReport_Click()
On Error GoTo Err_btnPrintReport_Click
Dim stDocName As String
stDocName = "Agreement"
Dim strWhere As String
If Me.Dirty Then 'save first
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select the record to print."
Else
strWhere = "[Customers_CustomerID] = " & Forms![ProjectsAll]![Customers
Subform].Form![Customers_CustomerID]
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
End If
Exit_btnPrintReport_Click:
Exit Sub
Err_btnPrintReport_Click:
MsgBox Err.Description
Resume Exit_btnPrintReport_Click
End Sub
Any help greatly appreciated
Thanks