Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Tool bars, Menu bars + Ribbon _ Connection Between Login Form And Ribbon

Posted by: Davecogz84 Aug 2 2019, 09:24 AM

Dear all,

I'm posting here in the hope that someone can help with something that's been trying my patience for days. The setup is simple:

I have a table with user names; the ribbon has a dropdown (ddcDropDown_) that pulls up the list of users, as does a combo box on the splash form (ComboMain). I would like the user to be able to click on either dropdown, and change the user. When he/she does that, the value will need to be passed from the ribbon to the form, or from the form to the ribbon.

I can get it to work from the ribbon: it passes the value to the form no problem. However, the other way round doesn't work: nothing happens at all. Below is the code I'm using and attached is a pared down version of the file.

Any help will be very much appreciated since I am pulling my hair out about this!

The XML for the dropdown button is:
<dropDown id="ddcDropDown_" label="DropDown:" getItemCount = "fncGetItemCountCbx"
getItemLabel = "fncGetItemLabelCbx" onAction="fncOnChangeCbx" getSelectedItemIndex="GetSelectedItemIndexDropDown" sizeString= "WWWWWWWWWW">

The only form I have is FMSplashAnalysis (that contains the combo box ComboMain) and the only table is TABStaff.

The relevant VBA code is:
(1) On the combo box:
Private Sub ComboMain_AfterUpdate()
lngDropDownValue = Me!ComboMain
gobjRibbon.InvalidateControl "ddcDropDown_"
End Sub

'(2) Relating to the XML
Sub fncGetItemLabelCbx(control As IRibbonControl, index As Integer, ByRef label)
label = DLookup("StaffSurname", "TABStaff", "ExtraID =" & index)
End sub

Sub GetSelectedItemIndexDropDown(control As IRibbonControl, _
ByRef index)
gobjRibbon.InvalidateControl "ddcDropDown_"
' Select Case control.ID
' Case Else
index = lngDropDownValue
' End Select
End Sub

Sub fncOnChangeCbx(control As IRibbonControl, selectedId As String, strText As Long)
Dim strNamePerson As String
strNamePerson = Nz(DLookup("StaffSurname", "TABStaff", "ExtraID=" & strText), "absent")
Dim strID As String
strID = Nz(DLookup("StaffID", "TABStaff", "ExtraID=" & strText), "absent")
[Forms]![FMSplashAnalysis]!ComboMain.Value = strID
End Sub ( 65.01K ): 6

Posted by: theDBguy Aug 2 2019, 09:56 AM


Welcome to UtterAccess!

I haven't tried it before but have you tried if you can set a default value to the ribbon dropdown? If so, then maybe you can change the default value when you invalidate the control.

Posted by: theDBguy Aug 5 2019, 03:17 PM

Hi Dave. Not sure if you already got it fixed but I gave it a try and attached is the result of my tests. Hope it helps... ( 51.43K ): 7

Posted by: Davecogz84 Aug 13 2019, 11:14 PM

Thanks so much, the DBguy. Your solution worked a charm. It was all about the default. One other clear fault with my previous method was that the column I'd called ExtraID (which was telling the combo box the order in which to put the combo items) was missing a zero. i.e. the first item in that list should have been zero.

Thanks again!

Posted by: fo_007_fo Aug 14 2019, 01:32 AM