Combo Box / Label Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • risk32
    New Member
    • Mar 2008
    • 98

    #1

    Combo Box / Label Help

    Hello all.
    I seem to have a problem displaying the correct value in a label for a combobox.
    In my table, I have a primary key (1-12) and a second column (January - December). Pretty self-explanitory. I have the combobox set to filter by primary key in ascending order, to make sure the months stay in the same format, instead of being alphabetical. Everything is A-OK, except one thing. With the onChange event for the combobox, I have a label that displays a caption, based on what the value of the box is. When the value changes, it displays the primary key when I want it to show the second field (the text of the month).
    Code:
    Private Sub cboMonth_Change()
    lblMonthLink.Caption = cboMonth.Value
    End Sub
    Does anyone know how to change it to show the second column in the caption instead of the primary?
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hello, risk32.

    Use "Column" property of Combobox class.

    Regards,
    Fish

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Since the columns are Zero-based the second column is actually Column 1

      Code:
      Private Sub cboMonth__AfterUpdate()
        lblMonthLink.Caption = cboMonth.Column(1)
      End Sub
      You'll also notice that I changed the code to the AfterUpdate event. Using the OnChange event will work if you users scroll to an item to select it, but if they try to use the AutoExpand feature, i.e. type in a letter or two so that Access will search out matches, then hit >Enter> ro select it, it'll fail.

      Linq ;0)>

      Comment

      Working...