Commanbar combo boxes (1 Viewer)

S

stinehelferw

Guest
Commandbar combo boxes

Using Access 2003

Modifying someone else's code. Always interesting.
This is a time scheduling program for a lab environment.

It was working, but I wanted to modify it so it used combo boxes for the submenu item selection.

I didn't have a great deal of luck so switched back to the original code, which I give in this post.

Oddly, when I run the application now, the messed up combo boxes are still in the right-click menu for this list box on the form.

I don't understand where this information is coming from.
I've saved the code, closed Access and reopened to no avail.

The code I'm modifying is in a module titled RightClickScheduler.

Here is the original code for a CommandBar received when right-click on a Lst control in a form. This is what I have reverted to with no combo box reference, but still have combo boxes in the right-click menu for the first commandbar. The second commandbar was never changed code-wise and still works as it always did.


Public Sub SeatMeatMenuBar()

Dim Mybar As CommandBar, MyControl As Controls, Rst As Recordset
Dim newButton As CommandBarButton, x As Integer

'''''''''''''''''''''''''''''''''
'remove all previous entries
''''''''''''''''''''''''''''''''''
For Each ctl In CommandBars("SeatmeatMsn").Controls("Msn Position").Controls
If ctl.Caption = "Remove Position" Then
Else
ctl.Delete
End If
Next ctl

For Each ctl In CommandBars("SeatMeat").Controls("WST Position").Controls
If ctl.Caption = "Remove Position" Then
Else
ctl.Delete
End If
Next ctl

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Create a button with text on the bar and set some properties.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set Mybar = CommandBars("SeatmeatMsn")

Set Rst = CurrentDb.OpenRecordset("SELECT Position.RefId, Position.Title,

Position.FltDeckRelated FROM [Position] WHERE Position.FltDeckRelated=false Order by

position.Title DESC ")
If Rst.BOF = True And Rst.EOF = True Then
Else
Rst.MoveLast
Rst.MoveFirst
For x = 0 To Rst.RecordCount - 1

Set newButton = Mybar.Controls("Msn

Position").Controls.Add(Type:=msoControlButton, Before:=2, Temporary:=True)
With newButton
.Style = msoButtonIconAndCaption
.Caption = Rst!Title
.OnAction = "=PositionAssigned(" & Rst!RefId & ")"
.Visible = True
.BeginGroup = IIf(x = Rst.RecordCount - 1, True, False)
End With
Rst.MoveNext
Next
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Create a button with text on the bar and set some properties.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set Mybar = CommandBars("SeatMeat")
Set Rst = CurrentDb.OpenRecordset("SELECT Position.RefId, Position.Title,

Position.FltDeckRelated FROM [Position] WHERE Position.FltDeckRelated=true order by

Position.RefId DESC")
If Rst.BOF = True And Rst.EOF = True Then
Else
Rst.MoveLast
Rst.MoveFirst
For x = 0 To Rst.RecordCount - 1
Set newButton = Mybar.Controls("WST

Position").Controls.Add(Type:=msoControlButton, Before:=2, Temporary:=True)
With newButton
.Style = msoButtonIconAndCaption
.Caption = Rst!Title
.OnAction = "=PositionAssigned(" & Rst!RefId & ")"
.Visible = True
.BeginGroup = IIf(x = Rst.RecordCount - 1, True, False)
End With
Rst.MoveNext
Next
End If
End Sub


__________________

How do I get back to square one?
 
Last edited:
S

stinehelferw

Guest
Access 2002 Desktop Developer's Handbook to the rescue

Figured it out.

Even though I had changed the code, the toolbar was defined internally as well.

Had to go to View>Toolbars>Customize
Under Toolbars tab select Shortcut Menus

This pops up a Shortcut Menus toolbar.
Select Custom>SeatmeatMsn (my custom menu)

From there able to right-click on menu items of my custom menu and delete them.

Now it looks like it did originally.

Still wish I had the combo box look rather than a long list, but I'll figure that out later.
 
S

stinehelferw

Guest
Got the combo boxes

Got the combo boxes working on the shortcut menu.
Woo hoo!
 

Users who are viewing this thread

Top Bottom