Fill list combo box from database
Fill list combo box from database
API Declarations
'[email protected]
'http://www.akaaz.cjb.net
Rate Fill list combo box from database
(1(1 Vote))
String)
On Error GoTo Errors
Dim rs As Recordset 'Declare a recordset
Dim sql As String 'Declare a string to hold the SQL statement
cboBox.Clear
sql = ""
sql = "SELECT " & IDField & ", " & descField & " FROM " & strTB
Set rs = db.OpenRecordset(sql, dbOpenForwardOnly)
With rs
Do Until .EOF 'Loop until the End of the recordset
cboBox.AddItem rs(descField)
cboBox.ItemData(cboBox.NewIndex) = rs(IDField)
.MoveNext
Loop
.Close
Debug.Print cboBox.Name & " was populated"
End With '(rs)
Set rs = Nothing 'Release the variable
Exit Sub
Errors: 'Error handler
If Err.Number <> 0 Then
MsgBox ("Error #: " & str(Err.Number) & Err.Description)
Exit Sub
End If
End Sub
Fill list combo box from database Comments
No comments yet — be the first to post one!
Post a Comment