Solved

Two forms open the same report

Posted on 2013-11-21
3
534 Views
Last Modified: 2013-11-22
Two forms can open the same report. When the report closes I want the form that opened the report to be re-opened. That is assuming that the form has to be closed before opening a report. One of the forms is a pop up and stays in front of the report until manually closed. So I have to close it first then open report. In the past I have copied the report renamed it and opened two different reports using the reports on close event to re-open the correct form, but that must be the wrong way to do it?

Access 2003
0
Comment
Question by:DatabaseDek
3 Comments
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 150 total points
ID: 39666998
You can use OpenArgs when you open the report:

DoCmd.OpenReport "reportname", WhereCondition := "Id = " & Me.ID, OpenArgs := Me.Name
DoCmd.Close acForm, Me.Name    '<--- close the form after opening the report.

And then in the close event of your report:

Docmd.OpenForm Me.OpenArgs
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 350 total points
ID: 39667106
I avoid opening, closing, and reopening  Forms unless absolutely required for some reason. Most of the time there is really no good reason.

I like to just hide the form not close it  using:

Me.Visible = False

In the on close event I look to see which form is loaded and make it visible again.

Example:

If CurrentProject.AllForms("FormName1").IsLoaded = True Then
    forms("FormName1").Visible = True
End If

If CurrentProject.AllForms("FormName2").IsLoaded = True Then
    forms("FormName2").Visible = True
End If

Open in new window


I find this can also dramatically improve performance
0
 

Author Closing Comment

by:DatabaseDek
ID: 39668943
Brilliant, both.

Thanks you
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now