Fill ComboBox using VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cynicon
    New Member
    • Feb 2010
    • 20

    Fill ComboBox using VBA

    Hi, every one

    I have a combobox called "Me.Cuadro_comb inado17" in ACCESS 2003

    How can I add a list via VBA

    I need to fill it with the next list

    "Cat"
    "Dog"
    "Fish"

    How can I do it?
  • mshmyob
    Recognized Expert Contributor
    • Jan 2008
    • 903

    #2
    Basically set your RowSource property for the combo box:

    Simplified version like so

    [code=vb]
    Dim strRowSource as String

    strRowSource = "Cat;Dog;Fi sh"
    Me.Cuadro_combi nado17.RowSourc e = strRowSource
    Me.Cuadro_combi nado17.Requery

    [/code]

    cheers,

    Comment

    • cynicon
      New Member
      • Feb 2010
      • 20

      #3
      Thank you so much it works perfect

      Comment

      • mshmyob
        Recognized Expert Contributor
        • Jan 2008
        • 903

        #4
        You're welcome.

        cheers

        Comment

        • beacon
          Contributor
          • Aug 2007
          • 579

          #5
          Personally, I would prefer to use a table for values like you listed cynicon and then write a SQL statement that populates the combobox using mshmyob's method.

          This prevents you from having to hard code the values, which I've always been taught to avoid if at all possible.

          Comment

          Working...