Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,834
    This is a technical issue, not a language issue.
    I meant perhaps someone here who can help who speaks the language, not just anyone.
    A small sample db might be a good idea. Perhaps all that's needed would be a ribbon without all the non-related features yet exhibits the problem.


    Good luck!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #17
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Got it - it's the getText element, for a comboBox - not sure for a dropDown, but it's not getText. When I put that in, the ribbon doesn't load. I'm guessing there is a similar element for dropDowns, but I don't know what it is. More research needed.

    I already had that code in my app, but there was an error in it, and it wasn't retreiving the new value correctly.

    I also found this, which talks about both comboBoxes and dropDowns:

    http://www.ribbons-access.com/ms-acc...tor-part-6.asp

    And I'm attaching a small DB with a custom ribbon, which I used to track down what was happening. I stripped all the Czech stuff out of it, so it should run on English machines. The custom ribbon tab is named Display, and the form opens automatically, with that custom tab activated. The ribbon contains only two controls, a comboBox and a dropDown, both populated from the same table. The listbox in the form shows the contents of the table, the two upper textboxes show what is selected in each ribbon control, and the bottom text box is used to edit the selected value from the table/listbox.

    When the table is updated, the ribbon controls are invalidated and so repopulated.

    If you feel like playing with it and come up with something new, I'd be happy to hear about it.
    Attached Files Attached Files

  3. #18
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,834
    a form that can change the values in the table. When I change the table, I need to update the dropdown.
    I have custom event procedures that trigger various things that change around the app, including this ribbon dropdown.
    Does this mean that since the edit form is missing from your sample that code to trigger a refresh of the list is missing?
    While waiting for an answer to that, I just had a notion. When you alter the list can you not just call LoadArray() and get the changes?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #19
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    Im not sure what your procedure is to edit the entry as I haven't followed the entire thread but if you move the loadarray, as micron suggests, to the end of the procedure it is reflected in the ribbon combobox

    Code:
    Private Sub txtEditTableEntry_AfterUpdate()
    Dim x$
    Debug.Print lstRibbonItems; lstRibbonItems.ItemsSelected(0)
    tmp = txtEditTableEntry
    x = "Update RibbonSource Set RibbonItem = '" & tmp & "' Where RibbonItem = '" & lstRibbonItems & "'"
    Debug.Print x
    CurrentDb.Execute x
    'LoadArray
    lstRibbonItems.Requery
    TestRibbon.Invalidate
    LoadArray
    End Sub
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #20
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,834
    Close, but that's not what I meant because if I'm correct the edit is happening in the ribbon control, not the form control.
    I just tested by adding LoadArray to the procedure so that it now looks like
    Code:
    Public Sub cboDataText(control As IRibbonControl, cboText As String)
    Form_RibbonTestForm.txtRibbonSelectionComboBox = cboText
    LoadArray
    End Sub
    Seems to work except I'm not clear if the form listbox is supposed to update as well. If so, then an update sql (on the table) should be able to do that, but I think the original problem was to have the change reflected in the ribbon control. It just so happens that the form textbox does get updated.

    EDIT - OK, false alarm. I see that the list isn't refreshing with what I've done because that was the goal. THAT might be because the Update needs to happen first.
    Back to the drawing board...
    Last edited by Micron; 02-05-2021 at 09:42 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #21
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    Close, but that's not what I meant because if I'm correct the edit is happening in the ribbon control, not the form control.
    I thought the form was updating the table which the ribbon combo is based on. Then you invalidate the control and re-load it.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #22
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,834
    I'm not saying you're off the rails, but I put your code in. The issue I have is that the form value does update as soon as this line executes
    Form_RibbonTestForm.txtRibbonSelectionComboBox = cboText

    but what you have seems to work with what ever the listbox selection is, which could be anything when it runs. BUT altering the value in code does not cause the afterupdate event to run - at least not for me. If I make the sub Public and call the AfterUpdate event after (in the above posted line) it will update whatever happens to be selected in the listbox.

    It's getting late so I'm going to sign off for tonight. Current thought is to create a form property and assign the ribbon value to it before it's updated (or use a global variable). Or maybe dig in to the properties of the ribbon control.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #23
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    No, Micron and Moke123, both of you have missed what I was after. Posts #1 and #10 outline what I was tying to do. And I have it - the sample DB I attached in post #17 performs the actions I want, but I have it all in one form, rather than the several forms in my original project. Those would have made the example unnecessarily complicated, so I put everything in one.

    The edit box at the bottom of the form allows editing of a value selected from the listbox. Typing the change and pressing Enter changes the value properly - the underlying table is updated, the listbox is refreshed, and both ribbon controls are invalidated, thereby triggering a reload. It all works exactly correctly. The two upper textBoxes only show what was most recently selected from the ribbon controls. They have no functionality attached. Clicking a value in the listBox places that value in the lower textBox, where it can be edited - nothing else. There is no mechanism for either adding or deleting values - that wasn't what I needed to test, so I didn't put it in. If you want to add or remove values, you have to manually edit the underlying table.

    The only thing that doesn't work is that the SELECTED text in the dropDown is not updated, the way it is in the comboBox. The getText element in the ribbon control's definition does that for the comboBox, but not for the dropDown. I don't know what the corresponding element is for a dropDown, but if I put getText in, the ribbon does not load. I don't know if there is some other element that does that, or if dropDowns simply can't do that. There are several differences between the two controls - they look the same, but there are slight differences in the way they operate, and in some of their capabilities. I need to do a bit more digging on that.

    The original issue was that the SELECTED value in my comboBox was not updating when the underlying list was updated, but I've tracked that down to a simple error in my code. The selected value WAS updating properly - it's just that an error in my code was supplying the wrong (old) value.

  9. #24
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    I think you need to add a callback to set the index of the dropdown.
    When I get time I'll see if I can do it.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  10. #25
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    See if this is closer to what you want.
    I deleted everything except the code for the dropdown to make it more manageable
    added a blank record to your table so that it opens with a blank DD.
    Added callbacks to get the index of the DD.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  11. #26
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    See if this is closer to what you want.
    I deleted everything except the code for the dropdown to make it more manageable
    added a blank record to your table so that it opens with a blank DD.
    Added callbacks to get the index of the DD.
    Thank you, the getSelectedItemIndex is the the element I needed for updating the dropDown. Another difference between the two - one takes text, the other takes an index value. Makes a certain amount of sense, I suppose - a comboBox will accept text that is not already a value in its internal list, while a dropDown will not.

    But I'm confused by one of your statements. Both of my ribbon controls already did start up blank, and they remain that way until a manual selection is made. The listbox is also null until a value is clicked on. What exactly does adding a blank record to the table achieve?

  12. #27
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    The drop down index is zero based so using 0 as the default index you get the first record in the DD. I dont think you can set an index to null. There may be a way around that but I'm not aware of it(yet, anyway.)
    Yours was blank because you did not have a callback setting it.

    btw, Take whatever I say about ribbons with a grain of salt. I know just enough to barely get by with them.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  13. #28
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    This just keeps getting goofier. After testing my mini DB and verifying that the code in my real DB was now correct, I still wasn't getting the updated value in the ribbon's comboBox. After a great deal of hair-pulling and inventive, I discovered that ribbon tabs are an issue.

    I didn't mention it initially, because it didn't even occur to me that it might matter, but apparently it does. The comboBox is on one tab, the button that calls my edit form is on another. When I update the table and invalidate the ribbon controls, the routine that is supposed to set the text in the comboBox does NOT run. It only runs after I close the edit form and when I switch tabs back to the one that has the comboBox. However, although it runs upon tab switch, the text supplied to the routine specified in the getText element does NOT get placed into the comboBox's display window.

    I then tried manually opening the edit form while still on the tab with the comboBox. Then the update routine does run when I issue the invalidate command, and the correct text does appear in the display window.

    But it gets even weirder. After having the proper term appear in the window, if I switch tabs to something else, then switch back to the tab containing the comboBox, the proper term has disappeared and it is back to the original, no longer correct term.

    The attached DB demonstrates this, 100% reliably. Changing a value in the edit box when the Display tab is visible changes the comboBox and dropDown both. Then switching to the Dummy tab and back to Display resets the comboBox back to its original value – the change was only in the display, but apparently not in the 'guts', whatever that means. Switching to the Dummy tab before changing the value in the edit box runs the update routine for both controls when switching back to the Display tab, but only the dropDown is actually updated. You can follow the Degug.Print command in the immediate window to verify what is running when. I'm now completely confused – what the hell does this control think it is doing? This feels like a serious design error – I can't believe that such behavior is by design.

    A dropDown does not exhibit this fractured behavior. Setting the dropDown's index makes the proper value appear and stay. The re-loading code is still not run when the invalidate command is issued, but also upon tab switch, but at least it works and stays.

    I thought about converting the entire set of ribbons from comboBox to dropDown. That might have been a better design choice right from the start, since I limit everything to values in the list. I have no need for the comboBox's ability to accept a foreign value – in fact, such an action by the user is always an error. However, I can't seem to reliably clear a dropDown. An index of zero selects the first item in the list. And index of -1 selects nothing, but I have to switch tabs and switch back to make the display clear – it doesn't go away on the invalidate command, even though the code that sets in a -1 does run. Switching tabs in code to another and back clears the display, but it's a dorky way to have to do it, and not all my forms have multiple tabs.

    If anyone has some ideas on the subject, I'd love to hear them.
    Attached Files Attached Files

  14. #29
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    Just looking at it quickly I see a couple things.

    Where are you getting the value for tmp$ ?

    I dont think you can set index to -1

    you invalidate the whole ribbon.
    Have you tried InvalidateControl "YourControlNameHere" ?

    I'll look at it further later on when I get a chance.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  15. #30
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Just looking at it quickly I see a couple things.

    Where are you getting the value for tmp$ ?
    txtEditTableEntry_AfterUpdate and cmdClearRibbon_Click

    I dont think you can set index to -1
    Well, I can. I don't know if it's legit to do so, or if it is an undefined operation with no guaranteed result from the callback, but it's just a numeric value. I set it, and the displayed value disappears from the dropDown's display box, but only after switching tabs. I don't know of any other way to clear the dropDown without removing the source list, and I need to do that.

    you invalidate the whole ribbon.
    Have you tried InvalidateControl "YourControlNameHere" ?
    Yes - same result.

    I'll look at it further later on when I get a chance.
    Okay, thanks. It may be that this 'just the way it works, deal with it', as are so many other nuisances. If so, I say it's a pretty poorly thought-out design.
    Last edited by pdanes; 02-08-2021 at 06:15 AM.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-29-2018, 09:09 AM
  2. Replies: 9
    Last Post: 10-23-2017, 06:32 PM
  3. Replies: 1
    Last Post: 07-09-2014, 03:36 PM
  4. Access 2010 Refresh VS Refresh ALL
    By Snwboarder1982 in forum Access
    Replies: 1
    Last Post: 09-09-2011, 04:07 PM
  5. Invalidating dropdown control on Access 2007 ribbon
    By kenwarthen in forum Programming
    Replies: 0
    Last Post: 08-16-2010, 09:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums