Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Modules (VBA Coding) FAQ

Access Environment

List CommandBar And ToolBar Icons by markphsd
Posted: 21 May 04 (Edited 21 May 04)

'Code By Mark Phillips
'Copy all of this code into a Module. To Run:
'Type CreateTestBar into your immideate window.
'Go back to the Access Shell to view the results

'Ever want to find a Icon that isn't listed
'when you are creating or editing a toolbar?
'I have, so I wrote this.

'The first function creates
'a toolbar that lists all of the possible icons
'that might be listed. They are indexed by number, i don't
'know how many there are, but I ran the check
'up to 5100.

'The second function is from a microsoft
'helpfile that checks to see if the db has a
'toolbar of the same name that you are creating.
'If there is a toolbar with the same name, it deletes it.
'I used a name that I don't think anyone will have.

'After you run the code. Go back to the access
'window and you will have a toolbar that lists
'numbers 1 to 100. Click on the first one and
'you will get  a list of 1 to 50 that shows all
'the icons and their id. The same goes for the
'rest of the list.

You will first need to add a reference to your Access Database. In the code window goto tools-->References then scroll down the list and selectthe Microsoft Office XX.X Object Library. Where XX is the version number of your access database.

Public Function CreateTestBar()
Dim i As Integer
Dim x As Integer
Dim y As Integer

'i  the popmenus
'x is the buttons
x = 1
i = 1
y = 1
strMenuName = "ButtonTest40833" 'Make sure you don't have a button named "ButtonTest40833", this function would delete it.
 If fIsCreated(strMenuName) Then
 End If

    Set cmdNewMenu = Application.CommandBars.Add(strMenuName, msoBarTop, True, False)
    For i = 1 To 100
           Set cctlSubMenu = cmdNewMenu.Controls.Add(Type:=10)
                                With cctlSubMenu
                                            .Caption = i
                                           .BeginGroup = True
                                End With
                                y = x + 50
                                For x = x To (y)
                                Set CBarCtl = cctlSubMenu.Controls.Add(Type:=msoControlButton)
                                            With CBarCtl
                                            .Caption = Chr(34) & x & Chr(34)
                                            .FaceId = x
                                            End With
    cmdNewMenu.Visible = True
End Function
Function fIsCreated(strMenuName) As Boolean

    Dim intNumberMenus As Integer
    Dim i As Integer
    intNumberMenus = Application.CommandBars.Count
    fIsCreated = False
    For i = 1 To intNumberMenus
        If Application.CommandBars(i).Name = strMenuName Then
            fIsCreated = True
            i = intNumberMenus
        End If
End Function

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close