PC Review


Reply
Thread Tools Rate Thread

Change a MenuBar at Runtime

 
 
dch3
Guest
Posts: n/a
 
      5th Aug 2008
I'm trying to build a custom MenuBar for my app. While I've got the bar up
and running, I need to know if its possible to dynamically Add or Delete
items at Run Time. I have several table setup that control the various Menu
Functions that a person has access to - based on their Windows ID. I'd like
to provide them with a Menu where the items reflected the functions that they
have access to.

Basically for one user..

FILE MENU FUNCTION EDIT
TRAILER DISPATCH
QUIT & EXIT

for another..
FILE MENU FUNCTION EDIT
PARTS INVENTORY
REPORTS
TRAILER DISPATCH
USER SETUP
QUIT & EXIT

 
Reply With Quote
 
 
 
 
dch3
Guest
Posts: n/a
 
      5th Aug 2008
Never mind, and for anyone interested here's the starter code...

Public Sub BuildMenuBar()

Dim targetMenu As Object
Dim i As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim newCommand As Object

Set targetMenu = Application.CommandBars("TFC Menu").Controls("Menu
Functions")

'Remove all of the items and start fresh
For i = 1 To targetMenu.Controls.Count
targetMenu.Controls(1).Delete
Next i

Set db = DBEngine(0)(0)

Set rs = db.OpenRecordset("SELECT * FROM USystblMenufunctions ORDER BY
intSortOrder")

While Not rs.EOF
Set newCommand = targetMenu.Controls.Add
newCommand.Caption = rs("txtMenuFunctionLongName")
'newCommand.IsPriorityDropped = True
'newCommand.OnAction
'newCommand.Parameter
rs.MoveNext
Wend

rs.Close
Set rs = Nothing
Set db = Nothing

Set targetMenu = Nothing

End Sub


"dch3" wrote:

> I'm trying to build a custom MenuBar for my app. While I've got the bar up
> and running, I need to know if its possible to dynamically Add or Delete
> items at Run Time. I have several table setup that control the various Menu
> Functions that a person has access to - based on their Windows ID. I'd like
> to provide them with a Menu where the items reflected the functions that they
> have access to.
>
> Basically for one user..
>
> FILE MENU FUNCTION EDIT
> TRAILER DISPATCH
> QUIT & EXIT
>
> for another..
> FILE MENU FUNCTION EDIT
> PARTS INVENTORY
> REPORTS
> TRAILER DISPATCH
> USER SETUP
> QUIT & EXIT
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Menubar based on Windows User LogonID Irshad Alam Microsoft Access Form Coding 3 30th Aug 2008 08:17 AM
Can I change the menubar to look like excel 2003? =?Utf-8?B?UnVkZSBSZWFsaXR5?= Microsoft Excel New Users 5 12th Jul 2007 03:39 AM
change to toolbar from menubar with no "view" option =?Utf-8?B?QW5uIExhbmdsZXk=?= Microsoft Access 2 25th Oct 2006 08:44 PM
programmatically change icons on a menubar akh2103@gmail.com Microsoft Excel Programming 2 26th Jul 2006 10:52 AM
Change menubar - VBA =?Utf-8?B?YW5u?= Microsoft Access VBA Modules 0 22nd Feb 2005 07:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:42 PM.