Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Posts
    20

    Post Populate combo box with Record Set in Access 2003

    Hi
    Im using a Combo box in my form which is used to populate values from a Table. I have used the following codes.
    1. <Code>
    Set db = CurrentDb()
    Dim Lrs As DAO.Recordset, lsql As String
    lsql = "select DeptName from Department"
    Set Lrs = db.OpenRecordset(lsql)
    While Not Lrs.EOF


    Me.cmbDept.AddItem Lrs.Fields("DeptName")
    Lrs.MoveNext

    Wend

    </Code>

    Im Getting The following error when i execute:
    "The RowSourceType Property Must be set to 'Value List' to use this method"

    What i need to do
    Plz Suggest

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi
    This is what I think you need to do:

    Take a look at the properties of the combo box. Click the "Data" tab. Change the "Row Source Type" setting to "Value List".
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi

    Just had another thought.

    Why not just set the "Row Source Type" setting to "Table/Query" and the "Row Source" property to "select YourTableName.DeptName from YourTableName.Department" without the quotes.
    Then you wouldn't need any code.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Access 2003: Many to many combo box
    By compooper in forum Forms
    Replies: 1
    Last Post: 06-17-2011, 04:07 PM
  2. Replies: 12
    Last Post: 06-14-2011, 01:42 PM
  3. Replies: 1
    Last Post: 04-21-2011, 11:27 AM
  4. Replies: 3
    Last Post: 01-28-2011, 11:42 AM
  5. Replies: 4
    Last Post: 01-24-2011, 07:11 PM

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