Hi Arvin
Thanks for the reply. Partial success!
If I print one record this works fine.
If I try to do 2 records, it prints 4 (2x2) ; 3 records gives 9 etc!
Obviously I have wrongly placed my two loop statements but can't see how to
fix it. Code shown below. Any thoughts?
Thanks
-----------------------------------------------------------------------------
Private Sub btnPrintPhotos_Click()
On Error GoTo Err_btnPrintPhotos_Click
'Bulk print class photos after warning user that
'printing many classes may take a long time
If Me.LstClasses.ItemsSelected.Count = 0 Then
MsgBox "You have not selected a set to print"
Exit Sub
End If
If Me.LstClasses.ItemsSelected.Count > 10 Then
Dim Msg, Style, Title, response, MyString
Msg = "Printing many sets of photos at once may take a long time" &
vbNewLine & _
"Are you sure you want to continue?" & vbNewLine & vbNewLine & _
"Click YES to continue printing these classes" & vbNewLine & _
"Click NO to return to the list of classes"
Style = vbYesNo + vbInformation + vbDefaultButton2 ' Define buttons.
Title = "WARNING" ' Define title.
response = MsgBox(Msg, Style, Title)
'If user chooses No, return to selection box.
If response = vbNo Then Exit Sub
'If user chooses Yes, continue printing
End If
'Continue printing if Me.LstClasses.ItemsSelected.Count is between 1 And 10
'Show progress meter
Dim Counter As Integer
SysCmd acSysCmdInitMeter, "Printing class photos: ", Me.txtTotalClass
For Counter = 1 To Me.txtTotalClass
SysCmd acSysCmdUpdateMeter, Counter
Dim ctl As Control
Dim varItm As Variant
Set ctl = Forms!PrintClassPhotos.LstClasses
stDocName = "rptClassPhotos"
For Each varItm In ctl.ItemsSelected
strClass = ctl.ItemData(varItm)
If Me.ChkPreview = True Then
DoCmd.OpenReport stDocName, acViewPreview, , "ClassID = '" &
strClass & "'"
Else
DoCmd.OpenReport stDocName, acViewNormal, , "ClassID = '" &
strClass & "'"
End If
Next varItm
Next Counter
'Remove progress meter
SysCmd acSysCmdRemoveMeter
Me.LstClasses.Requery
Me.txtTotalClass = 0
'Re-sort LstClasses by TeacherID
Dim sort As Integer
sort = basOrderby("TeacherID", "asc")
Exit Sub
Exit_btnPrintPhotos_Click:
Exit Sub
Err_btnPrintPhotos_Click:
MsgBox err.Description
Resume Exit_btnPrintPhotos_Click
End Sub