Opening report randomly causes errors

D

Don

Hello, I added code from the below Microsoft article to get users default
printer setting of A4 to show. It works fine but my users report that they
randomly(let's say every 30 time they run a report) get access error message
and then have to restart the application. Is there anything wrong with my
code below?

Thanks

Don

http://support.microsoft.com/?scid=kb;en-us;290293&spid=2509&sid=72


Private Sub PrintDetailList_Click()
sRoutine = "PrintDetailList_Click"
gError.AddRoutine smodule, sRoutine
On Error GoTo Err_Routine

'*************************** ACTIVE CODE ******************************
Dim sSQL As String
Dim sParam As String
Dim qryName As String

sSQL = "psp_InvoiceSearchReport "
sParam = vbNullString
sParam = spAddParameter(sParam, Me.PODetailID, "Number")
sParam = spAddParameter(sParam, Me.EntityID, "Number")
spReturnProcedure sSQL & sParam & ", 2"
qryName = "spExecute"
Dim rpt As Access.Report
Dim prtr As Access.Printer
Set Application.Printer = Nothing
Set prtr = Application.Printer
prtr.Orientation = acPRORLandscape

DoCmd.OpenReport "rInvoiceDetailSearchDetails", acViewPreview, qryName
Set rpt = Reports("rInvoiceDetailSearchDetails")
Set rpt.Printer = prtr


'**********************************************************************

Exit_Routine:
On Error Resume Next
gError.HandleError
Exit Sub

Err_Routine:
gError.SetError Err, smodule, sRoutine
Resume Exit_Routine

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top