Listbox to print reports

elsanto

Aspiring to Sainthood...
Local time
Tomorrow, 02:37
Joined
Jul 9, 2003
Messages
35
Hey all,

Still battling with this multi-select listbox problem.
I found the following code:

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


I think I get it all. But where does it specify the name of the report to print?
Cheers.
 
Code:
strValue = ListBoxName.ItemData(vntIndex)

The line above assigns a value (presumably, a name of a report) from a selected row in the listbox to a variable named strValue. The line below uses the variable to print a report of the same name.

Code:
DoCmd.OpenReport strValue, acViewNormal

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom