Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing and closing a form..runtime 2585.

Status
Not open for further replies.

ChrisCalvert

Technical User
Mar 18, 2002
231
0
0
US
I am trying to use a button to activate a 'printer friendly' version of a form. I want this to open to the same record as the 'normal version' form, print, and then close. I have the printing no problem, but I get a runtime 2585 because it seems like it is trying to close while it is printing. How can I get it to wait untill it is through printing then close? I am running 2000.
Here is the code so far:


Private Sub Form_Activate()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
DoCmd.Close
End Sub
 
The Follow Err Check is added to your code. If print isn't finished, it waits 3 seconds before it trys to close form again.

Private Sub Form_Activate()
on error goto Err_Form_Activate
Dim Start

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Close_Form:
DoCmd.Close

Exit_Form_Activate:
Exit Sub

Err_Form_Activate
If Err.Number = 2585 Then
Start = Timer ' Set start time.
Do While Timer < Start + 3
'Loops until time has passed , 3 = 3 seconds, change as needed
Loop
else
MsgBox Err.Description
End If
Resume Close_Form

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top