Speed up a procedure

J

James

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------------
 
Top