Hello,
I have two list boxes
The first list box shows the available reports that I can chose from.
The second list box will hold the reports that I have chosen from the first list box.
I have a button where I want to print the reports that have been chosen from the second list box.
If I chose one report from the second list box it works but if I chose more than one it doesnt.
I step through the code and it looks like it sees the reports as expected but it only prints the first one in the chosen list.
Here is the code for the buttons click event.
Private Sub CmdPreviewReports_Click()
Dim i As Integer
Dim strRepName As String
With Me.LstChosenReports
If (.ItemsSelected.Count > 0) Then
For i = 0 To .ListCount - 1
If .Selected(i) Then
If Not IsNull(.ItemData(i)) Then
'DoCmd.SetWarnings False
strRepName = Me.LstChosenReports.Column(0)
DoCmd.OpenReport strRepName, acViewPreview
'DoCmd.SetWarnings True
End If
End If
Next i
Else
MsgBox "You must chose at least one report to print"
Me.LstChosenReports.SetFocus
End If
End With
End Sub
I have two list boxes
The first list box shows the available reports that I can chose from.
The second list box will hold the reports that I have chosen from the first list box.
I have a button where I want to print the reports that have been chosen from the second list box.
If I chose one report from the second list box it works but if I chose more than one it doesnt.
I step through the code and it looks like it sees the reports as expected but it only prints the first one in the chosen list.
Here is the code for the buttons click event.
Private Sub CmdPreviewReports_Click()
Dim i As Integer
Dim strRepName As String
With Me.LstChosenReports
If (.ItemsSelected.Count > 0) Then
For i = 0 To .ListCount - 1
If .Selected(i) Then
If Not IsNull(.ItemData(i)) Then
'DoCmd.SetWarnings False
strRepName = Me.LstChosenReports.Column(0)
DoCmd.OpenReport strRepName, acViewPreview
'DoCmd.SetWarnings True
End If
End If
Next i
Else
MsgBox "You must chose at least one report to print"
Me.LstChosenReports.SetFocus
End If
End With
End Sub