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

How do I get rid of the default menu bar

Status
Not open for further replies.

Zygor

Technical User
Apr 18, 2001
271
US
I am tring to get rid of the File Edit View Insert Tools Window Help menu bar on my forms.

I have unchecked all options in the startup window, and I have an AutoExec macro that has ShowToolbar
- Form View No
- Form Design No
- Formatting (Form/Report) No
- Database No
 
maybe from Tools => customize, you can create your own, and assign it to all forms.
Don't forget to make it a "Menu" bar, not default, "Tool" bar!
 
Zion. I've read many of your posts and have learned lots from you. I value your opinion.

What do YOU do to stop users from selecting (for example ) Windows - Cascade?
 
This strategy works pretty well. I run this after a login screen to set different Db properties for "user" and "administrators". Originally I was only using the code to stop people from entering using the "shift open" method. This disallowed bypass. But you can expand the properties.

Code:
Function ChangeProperty(strPropName As String, _
 varPropType As Variant, varPropValue As Variant) As Integer
' The current listing in Access help file which will
' let anyone who can open the db delete/reset any
' property created by using this function, since
' the call to CreateProperty doesn't use the DDL
' argument

 Dim dbs As DAO.Database
 Dim prp As DAO.Property
 Const conPropNotFoundError = 3270

 Set dbs = CurrentDb
 On Error GoTo Change_Err
 dbs.Properties(strPropName) = varPropValue
 ChangeProperty = True

Change_Bye:
 Exit Function

Change_Err:
 If Err = conPropNotFoundError Then ' Property not found.
  Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
  dbs.Properties.Append prp
  Resume Next
 Else
  ' Unknown error.
  ChangeProperty = False
  Resume Change_Bye
 End If
End Function

Public Sub subSetAdminProperties()
   ChangeProperty "AllowBypassKey", dbBoolean, False
   ChangeProperty "AllowFullMenus", dbBoolean, True
   ChangeProperty "AllowSpecialKeys", dbBoolean, True
   ChangeProperty "AllowBreakIntoCode", dbBoolean, True
End Sub

Public Sub subSetUserProperties()
   ChangeProperty "AllowBypassKey", dbBoolean, False
   ChangeProperty "AllowFullMenus", dbBoolean, False
   ChangeProperty "AllowSpecialKeys", dbBoolean, False
   ChangeProperty "AllowBreakIntoCode", dbBoolean, False
   ChangeProperty "StartupShowDBWindow", dbBoolean, False
   ChangeProperty "", dbBoolean, False
End Sub
 
zygor, thank-you for the compliment!
I don't know personally, if that property exists or not.

MajP's code appears very handy, I'm actually going to
employ that myself, or at least keep it on hand.Thank-you MajP!
Not sure what results occur, if you elect to NOT
allowFullMenus, Whether it meets your needs or not?

Outside of that, try removing the Windows menu, from
your menu bar, or create your own MenuBar,
excluding that item.

From any window, click Tools => Customize,
once the dialog box appears,
you can simply click on the W
"Windows" Menu Item, drag it away from the Menu Bar,
until you see an "X" appear, beside your cursor.
Unclick, and it's gone.

Hope this helps.
 
MajP. Thanks for responding, but even after using your code, I have all the File Edit View Insert Tools Window Help options I had before
 
Here's what I was looking for.

Application.CommandBars("Menu bar").Enabled = False


Thanks to you guys for trying. I always appreciate the help.
 
That is nice Zygor!

Pampers [afro]
You never too young to learn
 
That is good Zygor,
I didn't realize you wanted to eliminate all menu items.
I was thinking create your own, then for desired forms,
OnLoad, use
Me.MenuBar = "NoWindowsMenu"(custom menu)

Either way, nice code!
 
I apologize, I misread what you wanted to do as well. You might be interested in this code. If you do not need menu bars, then maybe you do not need the application window as well. It is neat, but brings up some other issues. I did not write it, but got it off this site.
Code:
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Dim dwReturn As Long
Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
     
Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
End If
If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
End If
If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
End If
If StatusCheck = True Then
    If IsWindowVisible(hWndAccessApp) = 0 Then
        fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then
        fAccessWindow = True
    End If
End If
End Function

now in a popup form's load event
Private Sub Form_Load()
fAccessWindow "Minimize", False, False
End Sub

Works well as long as you go popup form to popup form.
 
Nice Nice MajP

Pampers [afro]
You never too young to learn
 
Thanks, but like I said I did not write it. One day I will sit down and learn the API. Anyone recommend a good resource?
 
Not offhand MajP.
If this is any consolation,
or maybe something you know already,
I simply google "API VBA...", and I found a plethora
of examples, API calls etc...
At the time, I wasn't looking for explanations,
but API calls, I did get.

Good luck, either way!
 
Here is one approach I've used in the pastto Hide Menus:

Function HideAllMenuItems()
'This will hide all menu bars and tool bars
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i
End Function

Function UnHideAllMenuItems()
'This will unhide all menu bars and tool bars
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = True
Next i
End Function

htwh,

Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
Good stuff Steve! Offers a little more control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top