O
Office User
(I'm reposting as received no reply. original post in Access Database Forms
6/20 with title preview only 1 report)
I'm working in Access 2000. I have a form with 2 different list boxes of
reports which comes from a ReportName table having user friendly names,
actual report name and code to determine which type of report.
I'm trying to program command buttons on the form - 1 button to preview
report and 1 button 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 which I
can adapt for Print using acViewNormal.
*****************************
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" is throwing if off somehow. I've also tried code without rptChoice
variable and just
used DoCmd.PrintReport Me![ctlCallReports], acViewPreview but get message
"method or data member not found". When I search VBA Help I've discovered
Print Method can only be used with the OnPrint Property and PrintReport
doesn't seem to be valid.
Thanks for any input,
Marcia
6/20 with title preview only 1 report)
I'm working in Access 2000. I have a form with 2 different list boxes of
reports which comes from a ReportName table having user friendly names,
actual report name and code to determine which type of report.
I'm trying to program command buttons on the form - 1 button to preview
report and 1 button 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 which I
can adapt for Print using acViewNormal.
*****************************
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" is throwing if off somehow. I've also tried code without rptChoice
variable and just
used DoCmd.PrintReport Me![ctlCallReports], acViewPreview but get message
"method or data member not found". When I search VBA Help I've discovered
Print Method can only be used with the OnPrint Property and PrintReport
doesn't seem to be valid.
Thanks for any input,
Marcia