Results 1 to 5 of 5
  1. #1
    dantheman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    6

    populate combobox using vba

    Hi everybody. I am trying to populate a combo box in a form using vba but don't know how. I tried messing around with the dlookup but could not get it to work.



    Can someone give me an example?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    What exactly are you going to do with the Combobox? For most tasks you can use the Combobox Wizard to set one up.

    Linq ;0)>

  3. #3
    dantheman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    6
    Quote Originally Posted by Missinglinq View Post
    What exactly are you going to do with the Combobox? For most tasks you can use the Combobox Wizard to set one up.

    Linq ;0)>

    Hi

    Basically I have a table called myCDS that has three rows: ID, Artist, Tracks

    I am trying to make a form in access. Their has to be a combo box that uses code to show the Artist of the current record. I have to use access, I am trying to learn Access and VBA.

  4. #4
    dantheman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    6
    Here is what I got so far:


    Private Sub Form_Load()
    Me.Caption = "Today is " & Format$(Date, "dddd mmm-d-yyyy")
    Me.RecordSource = "tblStore"


    cbo.RowSourceType = "Table/Query"
    cbo.RowSource = "SELECT Store FROM tblStore"
    End Sub

    Basically I would now like to highlight the value it is currently on

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Your combo has the column "Store" associated to it and no other. You can display this column in your combo by binding it to your combo.

    cbo.BoundCollumn = "1"

    I usually just use the properties window for this. I think you need the parenthesis.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Populate a ComboBox using a popup form
    By burrina in forum Forms
    Replies: 0
    Last Post: 02-26-2013, 11:30 PM
  2. Replies: 1
    Last Post: 02-04-2013, 09:48 AM
  3. Replies: 1
    Last Post: 01-16-2013, 03:32 PM
  4. How to populate combobox via VBA
    By chuki2 in forum Programming
    Replies: 7
    Last Post: 08-15-2012, 10:42 AM
  5. Replies: 4
    Last Post: 08-15-2011, 10:06 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