Hide MS Access window from code

Suppose you’re building an application in MS Access, and your user interface consists of only one form. You don’t want to show the main application window, just the form you’ve designed. The most obvious way to do this is by making your form a popup form and do a call to the Windows API

from the Form_Open event to hide the main Access window. This will work, but there is a catch. Your application won’t be visible anymore in the windows taskbar and will easily get lost behind other programs.

A better way is to not hide the main Access window, but to resize it and position it behind your form. Put the following code in your form’s VBA module.

When your form is opened, the dimensions of the main window are stored for future reference. Then it’s size and position are set to match that of your form’s. Also note that an icon for the form is loaded from file.

Because a form can be dragged across the screen we need to check if it’s position has changed. This is done using a timer. Set the form’s timer interval to about 100 milliseconds and place the following code in the form’s On Timer event procedure:

To make these API calls work, you need to put the following declarations and constants in a separate module

Happy coding!

5 thoughts on “Hide MS Access window from code

  1. can you please give a database example . coz when i try and do the instructions.. it’ll not work for me.. thnx alot

  2. wow.. ive it in my Database, and it really works.. thnk you very very much it did solve my problem. and its very informative

Leave a Reply

Your email address will not be published. Required fields are marked *