Link to home
Start Free TrialLog in
Avatar of AVSTEL
AVSTEL

asked on

Programatically populate a combo box from a recordset

Hi,

I have work out the following code to populate my combo box:

'Populating dropdown of Format
    Dim sqlFormat As String
    sqlFormat = "SELECT tblRef_Chartez.libelle FROM tblRef_Chartez ORDER BY tblRef_Chartez.libelle ASC"
    Set rs = con.OpenRecordset(sqlFormat)
    If rs.EOF Then
           'Me.cboFormat.AddItem ("Table is empty")
           Me.cboFormat.RowSource = "Table est vide"
    Else
        While (Not (rs.EOF))
            'Me.cboFormat.AddItem (rs(0)0
            Me.cboFormat.RowSource = Me.cboFormat.RowSource & (rs(0))
            rs.MoveNext
        Wend
    End If
    'End of dropdown

As the method AddItem doesn't work on Ms Access 2000, I did some research and I found that I can populate the combo box by RowSource method.
But to my surprise, I can get the item in the combo box but at one row level only.  All the items are shown mixed together on one line only.  

Can someone help me out please.  

Should I use another method other than RowSource or my code contains errors.

Regards
SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial