VBA to hide toolbars, etc. (1 Viewer)

darkmastergyz

Registered User.
Local time
Yesterday, 17:52
Joined
May 7, 2006
Messages
85
What VBA code should I use to hide the tool bars, menus, etc.? I'd like to make it as minimal (only showing forms) as possible. I know I can't hide the access window, but I'd like to hide as much as I can.
 

DJkarl

Registered User.
Local time
Yesterday, 19:52
Joined
Mar 16, 2007
Messages
1,028
What VBA code should I use to hide the tool bars, menus, etc.? I'd like to make it as minimal (only showing forms) as possible. I know I can't hide the access window, but I'd like to hide as much as I can.

Actually if you set your forms to Popup and Modal you can hide the Access window entirely using the ShowWindow API. If you do this though you will need to have a switchboard form or some other method for users to navigate to the forms, and you will have to set your application to close when the switchboard closes or else you will be left with a hidden Access process running in the background.

Code:
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Public Const SW_HIDE = 0

Function HideAccess()
      ShowWindow Application.hWndAccessApp ,SW_HIDE
End Function
 

darkmastergyz

Registered User.
Local time
Yesterday, 17:52
Joined
May 7, 2006
Messages
85
How can I set my application to close when the switchboard closes? Could you give an example? Thanks!! This code looks really good.
 

DJkarl

Registered User.
Local time
Yesterday, 19:52
Joined
Mar 16, 2007
Messages
1,028
How can I set my application to close when the switchboard closes? Could you give an example? Thanks!! This code looks really good.

In the Unload event for your switchboard or main form put

Code:
Application.Quit

This will close your database and Access
 

Banana

split with a cherry atop.
Local time
Yesterday, 17:52
Joined
Sep 1, 2005
Messages
6,318
Actually if you set your forms to Popup and Modal you can hide the Access window entirely using the ShowWindow API. If you do this though you will need to have a switchboard form or some other method for users to navigate to the forms, and you will have to set your application to close when the switchboard closes or else you will be left with a hidden Access process running in the background.

A note of caution. I've found this to be somehow flawed.

1) If the Access window is hidden, it is not accessible through taskbar, and not always via alt-tabbing.

2) Runcommand methods is no longer available, meaning you can't use those methods to save, delete, undo or manipulate records. While there are workarounds, they're just more hassle, and are error-prone.

In end, I simply gave up on using the API and deigned to simply maximize the form and restore the Access background so the desktop can be exposed.

Besides, this does not answer the OP's question. The answer is that if you search the forums, "Hide commands and toolbars", you'll find plenty of example of how to do this.
 

Users who are viewing this thread

Top Bottom