Link to home
Start Free TrialLog in
Avatar of Eric Sherman
Eric ShermanFlag for United States of America

asked on

Open a Report with Form Open Event and Display in front of the Form???

I have a main form that opens with the application.  I have added a "Alerts" report for certain information that will be displayed each time the user logs in thus loading Form1.  Form1's Open Even will open the Alerts report in preview mode.  The problem is the report opens behind Form1 making it useless right now.  

I've tried DoCmd.SelectObject acReport, "Report", False  after the DoCmd.OpenReport code to no avail.  Form1 is not Modal nor is it set to remain on top of all other forms.

Any ideas will be appreciated.

Thanks,

ET
Avatar of Norie
Norie

Are you closing the form as well as opening the report?
Avatar of Eric Sherman

ASKER

No, Form1 is the main form that controls the application.  The "Alerts" report should display (Preview Mode) after the user has logged in, From1 loaded.  The user can review it or print it then close it down.  It works, it just opens each time behind Form1.  I'm sure there's some way to make the report display on top of the form .... not behind it.

ET
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I ran across those recommendations earlier but in Access 2k ... the acDialog and the Popup Property is not available.  

I can use the DoCmd.Minimize in Open Event on Form1 and now I'm trying to Restore Form1 using the OnClose Event of the Report to no avail.

Forms!Form1.Restore or Forms!Form1.Maximize doesn't seem to work.

Any ideas ...

ET
Did you try the code I posted?
Thanks all for the Replies and I'm sure the two solutions will work in later versions of Access just not 2000.  I will use them there.  

Here's what worked Access 2k.

In From1 Open Event before the report opens ...

DoCmd.Minimize
DoCmd.OpenReport "Report1", acViewPreview


In Report1 OnClose Event .....

If CurrentProject.AllForms("Form1").IsLoaded = True Then
    DoCmd.SelectObject acForm, "Form1"
    DoCmd.Restore
End If


I like the two solutions provided by capricorn1 and boag2000 simply because it's less code and will use them later on but the method above works with Access 2k.

Thanks,

ET Sherman
<<<<<Did you try the code I posted?>>>>>

Yes, I got a VB Error and on the Report Properties ... there's not PopUp Setting available.  I assume you are using a later version than 2000.

ET Sherman
Capricorn1 ... Below is the error I receive while running the code you posted.

ET
VBError.png
LOL

Yeah, I presumed Acc 03 or higher...

I have seen this, but I don't know if it is applicable (or practical)
http://support.microsoft.com/kb/209938
....is it possible to just change the location of the code that opens the report?

ex. something like this:
 
If Report Needs to Show
    OpenForm
    OpenReport
Else
    OpenForm
end if