Using a listbox to print reports????

crispy02

Registered User.
Local time
Today, 14:03
Joined
Jun 20, 2002
Messages
10
Currently a have a form where the user can click on a button and runs a macro that produces a report in preview mode. I have a user who would like to press more than button at a time to run 3 reports a once. Or could I set up a listbox where he could select the reports he wants to run and have them run one after another or at the same time.
 
It is better to print the reports from a list box rather than have a seperate button for each report. Create a list box and set the multiselect to Simple. Place the following code behind a command button on the form that has the list box.


On Error GoTo Err_Print_ClickErr

Dim vntIndex As Variant
Dim strValue As String

If ListBoxName.ListIndex < 0 Then
MsgBox "Please select 1 or more items from the list"
Exit Sub
End If


For Each vntIndex In ListBoxName.ItemsSelected
strValue = ListBoxName.ItemData(vntIndex)
DoCmd.OpenReport strValue, acViewNormal
Next
Err_Print_ClickErr:
Select Case Err.number
Case 2501 'cancelled by user or no data for the report
MsgBox "Report cancelled or no data found for the report.", vbInformation, "Information"
' Case Else
' MsgBox "Error " & Err & ": " & Error$, vbInformation, "Print_Click()"
End Select
 
Hello DJN,

I'm in the same situation as Chris - having a button to run my reports. I'm new in Access 2000, but I know the basics of macros, forms, button. I tried the sample code supplied and can't seem to make it work. Presently, I have created all my parameter queries, created a report for each of the parameter queries and store the settings in a macro sheet. I then create a button that reference the report from the macro sheet. Now when the user clicks on the button the parameter query kicks in asking the question and the result is presented in a report.
My question is, is there a way to have a generic query without using parameters for each of the fields and also a generic report so when the user selects from the multiselect listbox it would print the report? :confused: Is there something I have to do in the listbox other than setting it to "simple"?
Thank you very much for your time and efforts in assisting me in advance.
 

Users who are viewing this thread

Back
Top Bottom