Link to home
Start Free TrialLog in
Avatar of Pelegrinus
PelegrinusFlag for United States of America

asked on

Hide Access Window and Still Show Popup Form

I have found and adapted code that will shrink the main Access window behind my startup popup form, so that the user is not distracted by the underlying Access window. The code uses user32 library functions and ultimately uses SetWindowPos to reduce the Access window size to 5% of its full size.  When closing the startup form, code includes the user32 library ShowWindow function to maximize the Access window. It works like a charm, except that the small Access window can be seen if one moves the currently visible popup form.

I've also seen similar code that claims to HIDE the main access window while still showing the popup form. That code uses user32 library funtions and ultimately uses the user32 library function ShowWindow function with the SW_HIDE (=0) paramater. The claim is that this hides the Access window and still allows the active form to be used. An example I've seen in several places on the web is at http://access.mvps.org/access/api/api0019.htm (code by Dev Ashish), where the key claim is: "This same function can also be used to completely hide Access window and just show your form on the desktop.  Make the form popup and from it's Open Event, call the fSetAccessWindow function with SW_HIDE as the argument."

I'm using Access 2010. When I follow these suggestions to the letter, both the Access windows and the popup form disappear, and I have to run a stand-alone module, outside the code that's supposed to run in the application I'm developing, to re-show both the Access window and the pop-up form.

Did the code to HIDE the Access window work prior to Access 2010 (or prior to Access 2007)? Or was the original "solution" not a working solution at all? Or is there something else I can do?
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
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
Avatar of Pelegrinus

ASKER

Thank you. I had already set the forms to popup mode, thinking that was enough. It appears that I must also set all forms both to popup and modal, as you suggested. With that, the application runs as if it were a stand-alone app.

I pass on the caution I've seen about using SetWindow SW_HIDE: If an error occurs in the code, the Access window does not reappear automatically. This is not a problem in runtime mode, because I don't want the Access window to show at any time. But it could be a problem during development. The recommended solution: in the error-trap code, include code to re-show the Access window. I'm not sure how practical that is for me at this stage of development, but I'm keeping it in mind.

Thanks again.
If you don't disable shortcuts, you can always use CTRL-G to open a code window, but your users won't have this functionality, and failure to have really good error handling could leave Access open in the background with no way to close it but the Task Manager.

I've used this for a couple of simple applications, but rarely use it any more.

If you don't mind my asking, why a "B".  What could I have done differently to get an "A"?
Fair question about the "grade." I thought (and think) I was being complementary and grateful with the middle grade. I think I reacted, in part, to your comment that you hadn't tested your response in Access 2010, as well as to the part of the solution that suggested using popup mode--in my question, I had said several times that I was using popup mode. But your suggestion re the modal mode was exactly what I needed, and I do appreciate your response!
Yes. I'll regrade. My misunderstanding of the grading process.