ImageCombo Before/After Update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #1

    ImageCombo Before/After Update

    Im trying to have some fun with the imagecombo control, but so far its alot more frustration then it is fun.

    From what I have understood I can't tie the imagecombobox directly to a field in a table in the same way I would do with a standard combobox, because what the imagecombobox tries to store is the text property (instead of the key property, however odd that might be)

    Therefore I want to store the Key property of the selected item, after it selected. Im therefore looking for a BeforeUpdate in which to "transfer" the selected key value to a hidden field.
    Does anyone have a elegant way of doing this? What I have so far is to do this storage in the LostFocus event, but I would like some additional code to run whenever the user has selected an item, and it just looks odd if I run the code when the user clicks somewhere else (I.e. the imagecombo looses focus)

    Any suggestions? (And no the imagecombo does not have a built in Before_Update, but im looking for something similar)

    If anyone knows a good resource site with imagecombo information, i'd like to know about that too.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    From what I have understood I can't tie the imagecombobox directly to a field in a table in the same way I would do with a standard combobox
    The ImageCombo Control has a Control Source Property and as such can be 'Bound' to a Field in a Table as long as that Table is the Record Source of the Form.

    Comment

    • TheSmileyCoder
      Recognized Expert Moderator Top Contributor
      • Dec 2009
      • 2322

      #3
      Yes, it does have a controlsource, but from what I have experimented with it, it will try to store the TEXT (The text displayed in the combobox) value in the bound field.
      So say the imagecombo lets me choose between 3 people, all 3 of which is of course in a seperate table, with an Autonumber primary key.
      I would like to store the primary key of the person, not the persons name.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        The following Code, placed in the Click() Event of an ImageCombo Control, will return the Key Value of the Item Selected. Is this what you are looking for?
        Code:
        Private Sub ImageCombo1_Click()
          MsgBox Me![ImageCombo1].SelectedItem.Key
        End Sub

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          Thank you very much, that worked.
          I didn't consider using that as it was not one of the options given when looking at the Events tab of the combobox's properties.

          Comment

          Working...