I have a database that uses the Preview and Print buttons that are available in Access 2003. The database is on a server used by 5 different locations. 4 of the locations can preview and print perfectly but the 5th location gets the attached messaged every time she tries to Preview or Print. She has no problems previewing or printing from the other databases I've set up, only this one. We've checked her printer - it seems to be fine. I did notice that when she tries to print and gets the error message, the program shuts down, but the "databasename".ldb file that opens when you open a database, stays open after the shutdown. You have to close it manually.
Again, ALL other locations work just fine in the exact same database. I'm copying my code below. Is there anything that anyone can see that would conflict with a Xerox printer in this code - or has anyone else ever had this happen?
Option Compare Database
Option Explicit
Private Sub cmdOpenReport_Click()
On Error GoTo Err_cmdOpenReport_Click
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.lstLocation.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Location"
Exit Sub
End If
'add selected values to string
Set ctl = Me.lstLocation
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
'open the report, restricted to the selected items
Dim strOtherWhere As String
Dim Otherctl As Control
Dim OthervarItem As Variant
'make sure a selection has been made
If Me.lstSeason.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Season"
Exit Sub
End If
'add selected values to string
Set Otherctl = Me.lstSeason
For Each OthervarItem In Otherctl.ItemsSelected
strOtherWhere = strOtherWhere & "'" & Otherctl.ItemData(OthervarItem) & "',"
Next OthervarItem
'trim trailing comma
strOtherWhere = Left(strOtherWhere, Len(strOtherWhere) - 1)
DoCmd.OpenReport "HarvestingSummary", acPreview, , "Location IN(" & strWhere & ") AND Season IN(" & strOtherWhere & ")"
Exit_cmdOpenReport_Click:
Exit Sub
Err_cmdOpenReport_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReport_Click
End Sub
Private Sub cmdPrintReport_Click()
On Error GoTo Err_cmdPrintReport_Click
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.lstLocation.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Location"
Exit Sub
End If
'add selected values to string
Set ctl = Me.lstLocation
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
'open the report, restricted to the selected items
Dim strOtherWhere As String
Dim Otherctl As Control
Dim OthervarItem As Variant
'make sure a selection has been made
If Me.lstSeason.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Season"
Exit Sub
End If
'add selected values to string
Set Otherctl = Me.lstSeason
For Each OthervarItem In Otherctl.ItemsSelected
strOtherWhere = strOtherWhere & "'" & Otherctl.ItemData(OthervarItem) & "',"
Next OthervarItem
'trim trailing comma
strOtherWhere = Left(strOtherWhere, Len(strOtherWhere) - 1)
DoCmd.OpenReport "HarvestingSummary", acNormal, , "Location IN(" & strWhere & ") AND Season IN(" & strOtherWhere & ")"
Exit_cmdPrintReport_Click:
Exit Sub
Err_cmdPrintReport_Click:
MsgBox Err.Description
Resume Exit_cmdPrintReport_Click
End Sub