Stop Code if Report is in Print Preview

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Stop Code if Report is in Print Preview

Post by Leesha »

Hi,
I have users who repeatedly forget to close a report before opening a form. This causes that are not an issue if the report is closed. I've been looking for code to that will give a warning to the user to close any open reports and stop the next form from loading if reports are open. Nothing I've tried works. What would a sample of this code look like?
Thanks!
Leesha

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stop Code if Report is in Print Preview

Post by HansV »

Perhaps

Code: Select all

    If Reports.Count > 0 Then
        MsgBox "Please close all reports, then try again!", vbInformation
        Exit Sub
    End If
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Stop Code if Report is in Print Preview

Post by Leesha »

Thanks Hans! It worked perfectly!!