Speed up a procedure.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2000 - I found some code that will get the list of printers and I have
the user select the printer from the dropdown box. The printer is stored as
a text value in tblPrinter. It works like it should. However, it runs slow.
Is there anyother method to speed up the proccess?

---------Start Form Code--------
Private Sub Form_AfterUpdate()
On Error GoTo Err_cmdDuplicate

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "You must complete package information before printing a
label.", , "PackageLog 2005"
Else

Dim strCurrentPtr As String
Dim strSlipPrinter As String

strSlipPrinter = DLookup("[Printer]", "[DefaultLabelPrinter]", "[ID]
= 1")
strCurrentPtr = GetDefaultPrinter
SetDefaultPrinter strSlipPrinter
DoCmd.OpenReport "PackageSlip", acViewNormal
DoCmd.OpenReport "MailboxSlip", acViewNormal
SetDefaultPrinter strCurrentPtr
End If

Exit_cmdDuplicate:
Exit Sub

Err_cmdDuplicate:
If Err = 2212 Then
Else
MsgBox "Error " & Err.Number & " " & Err.Description
End If

Resume Exit_cmdDuplicate

End Sub
-------------end of code------------
 
Hi James,

I presume you mean the GetCurrentPrinter() and SetCurrentPrinter()
calls, because there's nothing else that would make this code run more
slowly than normal.

At a guess there's nothing you can do about these, because they'll be
using API calls whose performance is determined by things beyond your
control (unless you can reduce the number of printers, use only local
printers, use only simple old-fashioned printers, etc.).

Access 2000 - I found some code that will get the list of printers and I have
the user select the printer from the dropdown box. The printer is stored as
a text value in tblPrinter. It works like it should. However, it runs slow.
Is there anyother method to speed up the proccess?

---------Start Form Code--------
Private Sub Form_AfterUpdate()
On Error GoTo Err_cmdDuplicate

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "You must complete package information before printing a
label.", , "PackageLog 2005"
Else

Dim strCurrentPtr As String
Dim strSlipPrinter As String

strSlipPrinter = DLookup("[Printer]", "[DefaultLabelPrinter]", "[ID]
= 1")
strCurrentPtr = GetDefaultPrinter
SetDefaultPrinter strSlipPrinter
DoCmd.OpenReport "PackageSlip", acViewNormal
DoCmd.OpenReport "MailboxSlip", acViewNormal
SetDefaultPrinter strCurrentPtr
End If

Exit_cmdDuplicate:
Exit Sub

Err_cmdDuplicate:
If Err = 2212 Then
Else
MsgBox "Error " & Err.Number & " " & Err.Description
End If

Resume Exit_cmdDuplicate

End Sub
-------------end of code------------
 
Back
Top