Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Two forms open the same report

Posted on 2013-11-21
3
Medium Priority
?
587 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 600 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 1400 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

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.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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 …

604 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