gojets1721
Registered User.
- Local time
- Today, 08:29
- Joined
- Jun 11, 2019
- Messages
- 430
I have the below 'openreport' vba which works great to open up a customer's history based on their customer ID. It is a command on a form which opens a customer's full purchase history.
However, i was curious if it was possible to modify so that if the customer ID field in the form reads 'n/a' then the button does nothing and no report is opened.
Suggestions?
However, i was curious if it was possible to modify so that if the customer ID field in the form reads 'n/a' then the button does nothing and no report is opened.
Suggestions?
Code:
Private Sub btnOpenCustomerHistory_Click()
On Error GoTo btnOpenCustomerHistory_Click_Err
strReport = "rptPurchaseHistory"
lngView = acViewReport
strWhere = "[CustomerID] ='" & Nz(Me.[CustomerID], 0) & "'"
DoCmd.OpenReport strReport, lngView, , strWhere
btnOpenCustomerHistory_Click_Exit:
Exit Sub
btnOpenCustomerHistory_Click_Err:
MsgBox "Error #" & Err.Number & " - " & Err.Description, , "Error"
Resume btnOpenCustomerHistory_Click_Exit
End Sub