Solved

Two forms open the same report

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

730 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