O
Office User
Working in Access 2000. I have a form with 2 different list boxes of
reports. There are 2 command buttons on the form - 1 to preview report and 1
to print. This was copied and adapted from the Northwind DB sample in
Access. I don't want to use AfterUpdate property for list box because I want
the user to have the choice of previewing or printing the selected report.
problem #1 - Right now I can select a report from both list. I only want
user to be able to select report from 1 list at a time.
problem #2 - I can't get the command buttons to carry out the task after a
report is selected. Below is the code I've attempted for Preview (I'll just
change acViewPreview to acViewNormal for Print command).
Private Sub cmdPreview_Click()
' Preview selected report
' adapted from Northwind Database sample from Microsoft
Dim rptChoice As String
rptChoice = "Me.[ctlAgentReports]" Or "Me.[ctlCallReports]"
If IsNull(Me.ctlCallReports) Or IsNull(Me.ctlAgentReports) Then
MsgBox "Please select a report", vbExclamation, "Problem running report"
Else
DoCmd.OpenReport rptChoice, acViewPreview
End If
End Sub
I'm getting type mismatch related to my rptChoice variable. I'm sure the Or
isn't the right format. I've tried it without rptChoice variable and just
used DoCmd.PrintReport Me![ctlCallReports], acViewPreview but get message
"method or data member not found"
Thanks for any input,
Marcia
reports. There are 2 command buttons on the form - 1 to preview report and 1
to print. This was copied and adapted from the Northwind DB sample in
Access. I don't want to use AfterUpdate property for list box because I want
the user to have the choice of previewing or printing the selected report.
problem #1 - Right now I can select a report from both list. I only want
user to be able to select report from 1 list at a time.
problem #2 - I can't get the command buttons to carry out the task after a
report is selected. Below is the code I've attempted for Preview (I'll just
change acViewPreview to acViewNormal for Print command).
Private Sub cmdPreview_Click()
' Preview selected report
' adapted from Northwind Database sample from Microsoft
Dim rptChoice As String
rptChoice = "Me.[ctlAgentReports]" Or "Me.[ctlCallReports]"
If IsNull(Me.ctlCallReports) Or IsNull(Me.ctlAgentReports) Then
MsgBox "Please select a report", vbExclamation, "Problem running report"
Else
DoCmd.OpenReport rptChoice, acViewPreview
End If
End Sub
I'm getting type mismatch related to my rptChoice variable. I'm sure the Or
isn't the right format. I've tried it without rptChoice variable and just
used DoCmd.PrintReport Me![ctlCallReports], acViewPreview but get message
"method or data member not found"
Thanks for any input,
Marcia