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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Report Preview when Menus/toolbars hidden 1

Status
Not open for further replies.

rphbrew

Technical User
Nov 30, 2002
40
US
I have a button that launches a report preview. With the security hiding the buttons, when you click the X to close the report it closes the database.

How do I allow the users to close the report to go back to the form they started on??

 
In the OnCLose property of the report, use a DoCmd.OpenForm "formname" to open a new form... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I tried that and it opens the form then closes the database.

 
Then somewhere in the code for the report, you are telling the database to be closed...look in the OnClose event, or the OnUnload event....

and when you say closes the database, do you mean Access goes completely away....or just the database window??? Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I have all toolbars and menus hidden, so when I hit the button it launches the report in Preview mode, This takes up the entire screen and there is only one-(1) "X" in the upper right hand corner.

This appears to be the only way to exit the report. This also exits Access completely.

 
Ah.....there is the problem.......

you are not really exiting the report then.....you are using the close button of Access to close the report....this works only because before Access can close it must close all the objects it currently has open and in use....

now that we have fully identified the problem, we can look for a solution.....first, is your report maximized due to you opening a form maximized? Once you set one object to maximum, all object will be. To get around this, you can use the OnOpen event of the report to restore th size of the report to be normal.....use:

DoCmd.Restore

in the event and it shoudl work.

That is the first step....if that doesn't work, try not opening the form with a maxmize statement...instead open your form in design mode and develop it so it is just a tiny bit smaller than the screen...it will basically look maximized, but won't force everythign else in the database to be maximized.....and then you will have the buttons to close it available....

One last thing is to check the properties of the report for the property called CloseButton...set it to true or yes and you will just get the close button for that report. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I have written code that hides all toolbars and menu items to the general user population.

I am going to have to put code into the open report button to show the buttons then code in the close report properties that disables the buttons again?

I tried what you suggested and it did not work.

I appreciate your help.
 
I would say that yes, as you currently have the setup you will....

But here's a kewl idea you may want to try....
create a small form...onthe form put one button, close. COde this button to close the report and itself. set the popup protery of this form to yes. In the OnOpen event of the report, include some code to open this form also....

So, when you open the report, the report also opens this small popup form with a close button on it. The form is set to popup so it is always on top of the report....the users view the report, then click this little form button which in turn closes the report, itself, and reopens the original form if necessary....

let me know if you want an example or something.....should work for you... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Works like a charm.

thanks a lot for your help
 
Robert, on a form I have about 20 labels with report names on them. When someone selects a label it will open a report. When the report opens, it also opens another form that simply states "Would you like to print the report for Close the report?" Then there are two labels. One for Close and one for Print. Only when they select close it only closes the form and not the report. From reading a ton of threads I gather the DoCmd.Close Report requires a specific report name. Am I going to have to make individual forms for each report or is there a generic way to call all forms like DoCmd.Close *.forms.

Thanks for your help. I have spent all morning reading threads trying to find resolution for this problem. Hope you can help. Janet Lyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top