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(sqlForma t)
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
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(sqlForma
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.