How to check when Form Preview is closed? (1 Viewer)

martin155

New member
Local time
Today, 22:21
Joined
Sep 25, 2020
Messages
2
Hi, I am opening the print preview from form and I would like to know when user closes the preview so I can close the form window from VBA. Is it possible to somehow check when the Preview is closed? Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:21
Joined
May 7, 2009
Messages
19,169
you may try the Form's timer event to check if the report is still open:

private sub form_timer()
if syscmd(acSysCmdGetObjectState,acreport,"report_name")=0 then
'preview or report is close
end if
end sub
 

bob fitz

AWF VIP
Local time
Today, 21:21
Joined
May 23, 2011
Messages
4,717
Hi, I am opening the print preview from form and I would like to know when user closes the preview so I can close the form window from VBA. Is it possible to somehow check when the Preview is closed? Thank you
If you open a report in Print Preview you could use the reports Close event to close the form.
 

martin155

New member
Local time
Today, 22:21
Joined
Sep 25, 2020
Messages
2
I am opening the Form in Print Preview. So I would have to use the Report instead in order to be able to do this?
 

Isaac

Lifelong Learner
Local time
Today, 14:21
Joined
Mar 14, 2017
Messages
8,738
Hi, I am opening the print preview from form and I would like to know when user closes the preview so I can close the form window from VBA. Is it possible to somehow check when the Preview is closed? Thank you
My advice would be to approach these types of situations by simply disabling the red X (close) button on the form and explicitly coding a command button, both to open in print preview as well as close - that way you're in control and can do everything needed in the button's click event, rather than having to hook into events. However, I've never tried to "print preview a form" before so that's about the only advice I can give.
Good luck!
 

Users who are viewing this thread

Top Bottom