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?
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: