Custom Menus in 2007

L

Larry Salvucci

I'm trying to get custom menus to load when certain users log into the DB.
Here is what I'm using as a public function. I have it firing through my
AutoExec macro. Why is it always loading the "CustomMenuLS" no matter what
the Dlookup finds?

Public Function CustomLoad()

Dim intStore As Variant
Dim intStore1 As Variant
Dim intStore2 As Variant

intStore = DLookup("[AdminMenu]", "tblUsers", "[UserName] =
CurrentUser()")
intStore1 = DLookup("[AdminMenu]", "tblUsers", "[UserName] =
CurrentUser()")
intStore2 = DLookup("[AdminMenu]", "tblUsers", "[UserName] =
CurrentUser()")


If intStore = "0" Then
Application.CommandBars("CustomMenuLS").Enabled = True
Application.CommandBars("CustomMenu").Enabled = False
Application.CommandBars("CustomMainMenu").Enabled = False
Else

End If

If intStore1 = "1" Then
Application.CommandBars("CustomMenu").Enabled = True
Application.CommandBars("CustomMainMenu").Enabled = False
Application.CommandBars("CustomMenuLS").Enabled = False
Else

End If

If intStore2 = "2" Then
Application.CommandBars("CustomMainMenu").Enabled = True
Application.CommandBars("CustomMenu").Enabled = False
Application.CommandBars("CustomMenuLS").Enabled = False
Else

End If

End Function
 
B

banem2

Larry said:
I'm trying to get custom menus to load when certain users log into the DB.
Here is what I'm using as a public function. I have it firing through my
AutoExec macro. Why is it always loading the "CustomMenuLS" no matter what
the Dlookup finds?

Public Function CustomLoad()

Dim intStore As Variant
Dim intStore1 As Variant
Dim intStore2 As Variant

intStore = DLookup("[AdminMenu]", "tblUsers", "[UserName] =
CurrentUser()")
intStore1 = DLookup("[AdminMenu]", "tblUsers", "[UserName] =
CurrentUser()")
intStore2 = DLookup("[AdminMenu]", "tblUsers", "[UserName] =
CurrentUser()")


If intStore = "0" Then
Application.CommandBars("CustomMenuLS").Enabled = True
Application.CommandBars("CustomMenu").Enabled = False
Application.CommandBars("CustomMainMenu").Enabled = False
Else

End If

If intStore1 = "1" Then
Application.CommandBars("CustomMenu").Enabled = True
Application.CommandBars("CustomMainMenu").Enabled = False
Application.CommandBars("CustomMenuLS").Enabled = False
Else

End If

If intStore2 = "2" Then
Application.CommandBars("CustomMainMenu").Enabled = True
Application.CommandBars("CustomMenu").Enabled = False
Application.CommandBars("CustomMenuLS").Enabled = False
Else

End If

End Function

Access 2007 uses ribbon although it can show a menu using ribbon.
Assuming you are talking about menu, then try with:

DoCmd.ShowToolbar "CustomMenu", acToolbarNo
DoCmd.ShowToolbar "CustomMenuLS", acToolbarYes

This will hide first and show second menu. Don't be confused with
"ShowToolbar", this applies to menu too which is actually a case of
toolbar.

Regards,
Branislav Mihaljev
Microsoft Access MVP
 

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