PC Review


Reply
Thread Tools Rate Thread

How to Close Reports If Open

 
 
doyle60@aol.com
Guest
Posts: n/a
 
      5th May 2006
I have code that closes down forms if open. I tried to adapt it to a
report but it doesn't seem to work:

If IsOpen("SelfPrintNewrpt01a") Then
DoCmd.Close acReport, "SelfPrintNewrpt01a"
End If

If I remember correctly, Access 95 did not have an IsOpen function and
I had to create a module. But Access 97, which I presently have, does
have one. Anyway, the IsOpen function is working on the forms but not
on reports as above. What to do? Thanks,

Matt

 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      5th May 2006
On 5 May 2006 08:48:41 -0700, (E-Mail Removed) wrote:

> I have code that closes down forms if open. I tried to adapt it to a
> report but it doesn't seem to work:
>
> If IsOpen("SelfPrintNewrpt01a") Then
> DoCmd.Close acReport, "SelfPrintNewrpt01a"
> End If
>
> If I remember correctly, Access 95 did not have an IsOpen function and
> I had to create a module. But Access 97, which I presently have, does
> have one. Anyway, the IsOpen function is working on the forms but not
> on reports as above. What to do? Thanks,
>
> Matt


I believe you are thinking of the IsLoaded() function for forms, not
IsOpen().

Why do you need to see if it is open?
Just close it.
DoCmd.Close acReport, "SelfPrintNewrpt01a"
You will not get an error if it is not open.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
Douglas J Steele
Guest
Posts: n/a
 
      5th May 2006
Actually, Access 97 doesn't have an IsOpen function built into it: you must
have a library added to your application (or the function has been defined
in one of your modules)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have code that closes down forms if open. I tried to adapt it to a
> report but it doesn't seem to work:
>
> If IsOpen("SelfPrintNewrpt01a") Then
> DoCmd.Close acReport, "SelfPrintNewrpt01a"
> End If
>
> If I remember correctly, Access 95 did not have an IsOpen function and
> I had to create a module. But Access 97, which I presently have, does
> have one. Anyway, the IsOpen function is working on the forms but not
> on reports as above. What to do? Thanks,
>
> Matt
>



 
Reply With Quote
 
doyle60@aol.com
Guest
Posts: n/a
 
      5th May 2006
Because I have a situation where as many as nine reports open and all
of them have photographs on them. They are a pain to close down. If I
don't get the error if not open, I'll do it your way. Thanks.

Yes, I do have a module with the IsOpen function in it. But I guess I
didn't find it. It's there, somewhere.

Thanks all,

Matt

 
Reply With Quote
 
fredg
Guest
Posts: n/a
 
      5th May 2006
On 5 May 2006 12:53:35 -0700, (E-Mail Removed) wrote:

> Because I have a situation where as many as nine reports open and all
> of them have photographs on them. They are a pain to close down. If I
> don't get the error if not open, I'll do it your way. Thanks.
>
> Yes, I do have a module with the IsOpen function in it. But I guess I
> didn't find it. It's there, somewhere.
>
> Thanks all,
>
> Matt


Even if it did throw an error, you can trap it:

On Error GoTo Err_Handler
DoCmd.Close acReport, "SelfPrintNewrpt01a"
Exit_Sub:
Exit Sub
Err_Handler:
If Err = ???? Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub

Change ???? to whatever the actual error number is.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close all reports Leslie Isaacs Microsoft Access Reports 5 25th May 2007 04:14 PM
Close all reports Leslie Isaacs Microsoft Access Form Coding 5 25th May 2007 04:14 PM
Close Open Reports with Code =?Utf-8?B?S2lyayBQLg==?= Microsoft Access Form Coding 1 8th Dec 2005 03:08 AM
Unable to run Reports or open reports in design view =?Utf-8?B?TVNGVw==?= Microsoft Access 0 30th Nov 2005 08:36 PM
Reports close access James Johnson Microsoft Access Reports 2 26th Aug 2003 02:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 PM.