Solved

Two forms open the same report

Posted on 2013-11-21
3
542 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

792 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