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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mistake when cancelling printing dialog window

Status
Not open for further replies.

Bresart

Programmer
Feb 14, 2007
314
ES
Hi, i am using Access 2000. I have a button in a emerging form with the code:

Application.Echo False
DoCmd.OpenReport "infGlosar", acViewPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "infGlosar"
Application.Echo True

By pressing this button, the print dialog window opens. If i cancel this window, after closing the emerging form the exact area in which this form was placed is occuped by a grey uniform color, the same color that the background of Access with DB window not maximiced. I have catched this with Err.number 2501, but i haven't added a workable code.

Is that usual? Is there a way to handle it?

Thanks for looking.
 
remember that cancel is actually treated as an error, therefore will be caught and skipped like an error.

either move the application.echo true to after the error processing or move the error processing to before the application.echo true

--------------------
Procrastinate Now!
 
Thanks, Crowley16, it works perfectly.

Only that the form behind the emerging one doesn't stay maximiced. Does exist any way for avoiding this uggly effect?

The modified code is:

On Error GoTo ErrLab

Application.Echo False
DoCmd.OpenReport "infGlosar", acViewPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "infGlosar"
'Application.Echo True


ErrLab::

If Err.Number = 2501 Then
DoCmd.Close acReport, "infGlosar"
DoCmd.SelectObject acForm, "frmGlosar"
End If

Application.Echo True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top