Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide the form that previews report 4

Status
Not open for further replies.

ggoldberg

MIS
Feb 7, 2003
27
I would like to give the user the option to "Print" or "Preview" a report. I am trying to run this report from a "popup" and "modal" calling form, but when I choose "Preview" for the report (OpenReport "report1",acViewPreview),
the report is always hidden behind the calling form. I have tried to hide the calling form in it's own code by setting it's visibility to false before I call the report and to true after the report closes. I have used both
me.visible and forms!myForm.visible to do this, but in either case, the calling form continues to obscure to view'd report. I have also tried to hide/unhide the calling from from the open and close events in the report,
but have had the same problem.

Can anyone show me how to hide the calling form while the view'd report is open?

Thanks,

Gerry Goldberg

 
The whole idea behind a Popup/Modal form is so the user can't get paste acting upon it until it is closed. Everthing that is frustrating you about the form is exactly why the properties were created to allow the programmer to create such a monster.

Why don't you just use a regular form with AutoCenter and when the user selects the report to be run the preview will appear and the form will be hidden behind it. When the user reviews and/or prints the report and closes the window the calling form is centered as directed and ready to accept another selection from the User.

I use my Reports Menu in just this manner and have never had a problem. Let me know why that wouldn't work in your situation. Maybe you have something special that you need done and we can address it another way. Bob Scriver
 
I agree with your analysis and your solution has fixed my problem. But that I still don't understand why I can't seem to hide the calling form, either from it's own code or from the code in the report. In the calling form, I've tried:
me.visible=false
as well as
forms!callingForm.visible=false

In the report's Open event, I tried:
forms!callingForm.visible=false
and in the report's Close event, I tried:
forms!callingForm.visible=true

None of these had any effect. Why?

Thanks for your help.

Gerry Goldberg
 
I have tried all of the options as you described and yes I have found the same thing. The form will not become invisible in the OnLoad, OnOpen, or Current event procedures. It will not even become invisible if the me.visible = false is put in the Got Focus event of the first tab ordered control. But, it will disappear if the code is put in the OnClick event on the form.

Now that said, I still fail to understand why you would want to make the form invisible for any reason. The Popup / Modal form properties are made for it to stay on top and force an action. If you want to make it invisible then close the form like I said before. You are asking to do something I believe that makes little sense considering the properties selected. The action is not compatible with the type of form selected.

Good luck. Bob Scriver
 
GGoldBerg :

Here's how to make your forms invisible:

1) Create a PUBLIC variable and call it something with meaning, such as gstrPrevForm - string data type.

2) At any time in your code when the report is to be opened, place this line immediately on top of it:

gstrPrevForm = me.name

3) In the report's OnOpen event:

Application.forms(gstrPrevForm).visible = false

4) And in the report's OnClose event:

Application.forms(gstrPrevForm).visible = true

And that's it ...

The reason I do it this way it that I use the AutoCenter property in conjunction with the popUp property set to true. If the user of my database open the forms in order of 1, 2, 3, 4, I need them to close the forms in order of 4, 3, 2, 1 ... hence the need for popUp forms. However, say on form 4, the user has the option to print a report: in this case, rather than looking at a cluttered screen of forms and a report buried in behind all 4 forms, I hide all forms and open the report maximized: when the report closes, the screen reverts to it's previous state.

HTH

Greg If you don't understand, just nod and smile ...
 
Actually, this form-hiding technique was developed because this application often has a large sequence of forms opened one after another. Because some of the forms were much larger that others, it seemed prudent to hide each calling form (so as not to confuse the user) after it invoked the next form in the sequence. I see now that this was probably not necessary and could have been eliminated with a more efficient application design. At any rate, your suggestions were right on the mark and I appreciate your help.

Thanks again,

Gerry Goldberg
 
Another solution is to make your calling/controling form popup only (Not Modal)
Now the form will show on top but when you call preview or print you can make the form invisible.

FYI, As a previous reply stated:
When you select Modal, the form that is running will remain on top until closed. So only use Modal as a form property when nothing else should be on the screen until that form is complete and closes.

Hope this helps...
Access Add-on developer
 
Bob Scriver was kind enough to put me onto this thread. Greg's solution has solved my problem too. Here is star for you.


Cheers

AK
 
Bob, thank you for your help. I had a Popup/Modal open with a query and then was not able to edit the query. Your explanation was wonderful. However, on the same Popup (no longer a Modal) is a button which will close the query, open a form, and close the Popup. It is closing the query but stops there. Seeing the code below can you see an obvious reason why? Appreciate your help, JL

Private Sub Label9_Click()
DoCmd.CLOSE acQuery, "QRY-MoInvbyClient", acSaveYes
DoCmd.OpenForm "FRM-EOM-MoInvComp", acNormal
DoCmd.CLOSE
End Sub
 
Is your form "FRM-EOM-MoInvComp" being opened at all with this code? Try putting a STOP command at the beginning of this code and then step(F8) through it one line at a time to see just what is opening and closing and when.

Let me know what you experience.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Once it closes the query it does nothing else. Is that what you were looking for? Thanks for the help, JL
 
Change the DoCmd.Close to the following:

DoCmd.Close acForm, "FRM-EOM-MoInvComp"

Post back with the results.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Sorry, I mean the name of the popup form:

DoCmd.Close acForm, "popupformname"


Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Man your good. Worked perfectly. Thanks for taking the time to help me. Have a wonderful day and a pink star. Janet Lyn
 
I am happy that I could help you. Thanks for the Star.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top