Take Access 2000 menu bar out

A

Alex Martinez

Hello,

I am developing a small database using Access 2000 for non MS Access users.
My problem is when the user open the database via a icon on the desktop I
don't want the user have any access at all of Access menu bar (File, Edit,
View, Insert, etc.) All I want them to do is to open the file and my form
will appear. How does one code this. I also want the user have access to
the menu bar when they are accessing another MS Access file other then my
own . Any suggestion, tips, examples, or advice will be appreciated. Thank
you.
 
P

Philo Hamel via AccessMonster.com

Hi Alex,

Under the Tools menu you will find Startup... (I hope these are the right
names, I'm using the Dutch version). Here you can define which form to open
and which menus should be disabled.
Since I was looking for the same thing a while back and in addition wanted to
disable functions in the menu (like Close and the X in the top right corner)
I've added some code below. It might come in handy!

Later,
Philo




Put the following in the first form that opens (like a switchboard for
instance):

Private Sub Form_Open(Cancel As Integer)

Call SetEnabledState(False)

End Sub


Create a Module with this code:

Option Compare Database
Option Explicit

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As _
Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long

Const MF_GRAYED = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&

Public Function SetEnabledState(blnState As Boolean)
Call CloseButtonState(blnState)
Call ExitMenuState(blnState)
End Function

'Disable the Menu Option
Sub ExitMenuState(blnExitState As Boolean)
Application.CommandBars("File").Controls("Close").Enabled = blnExitState
Application.CommandBars("File").Controls("Exit").Enabled = blnExitState
End Sub

'Disable the Close Button Option
Sub CloseButtonState(boolClose As Boolean)
Dim hWnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim result As Long

hWnd = Application.hWndAccessApp
hMenu = GetSystemMenu(hWnd, 0)
If Not boolClose Then
wFlags = MF_BYCOMMAND Or MF_GRAYED
Else
wFlags = MF_BYCOMMAND And Not MF_GRAYED
End If

result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top