antonyx
Arsenal Supporter
- Local time
- Today, 10:58
- Joined
- Jan 7, 2005
- Messages
- 556
Code:
Private Sub btnPreviewReport_Click()
On Error GoTo Err_btnPreviewReport_Click
Dim stDocName As String
stDocName = "rptInvoice"
DoCmd.OpenReport stDocName, acPreview
Exit_btnPreviewReport_Click:
Exit Sub
Err_btnPreviewReport_Click:
MsgBox Err.Description
Resume Exit_btnPreviewReport_Click
End Sub
i want to change this code which is currently on my form...
i want to open a specific report based on the first three letters of a control called txtInvoiceRef
so something like this perhaps??
Code:
Private Sub btnPreviewReport_Click()
On Error GoTo Err_btnPreviewReport_Click
[b]If txtInvoiceRef (first 3) = MCD Then
DoCmd.OpenReport rptMCD (report name), acPreview
ElseIf
txtInvoiceRef (first 3) = BBC Then
DoCmd.OpenReport rptBBC (report name), acPreview
End if[/b]
Exit_btnPreviewReport_Click:
Exit Sub
Err_btnPreviewReport_Click:
MsgBox Err.Description
Resume Exit_btnPreviewReport_Click
End Sub
i know its a poor attempt.. but this is the jist of what i am trying to do..
thanks.