This code helps u to fill any combobox. One routine fits all
This code helps u to fill any combobox. One routine fits all
Rate This code helps u to fill any combobox. One routine fits all
(1(1 Vote))
Call FillComboBox(cmbArtist, "Select Artist from Bands", "Artist")
' The subroutine FillCombobox
Public Sub FillComboBox(Comboboxname As ComboBox, SQL As String, Fieldname As String)
Dim ado As ADODB.Connection
Dim rsTemp As ADODB.Recordset
Set ado = CreateObject("ADODB.Connection")
ado.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CDCollectie.mdb;Persist Security Info=False"
Set rsTemp = CreateObject("ADODB.Recordset")
With rsTemp
.LockType = adLockReadOnly
.CursorType = adOpenForwardOnly
.Open SQL, ado
End With
Comboboxname.Clear
Do While Not rsTemp.EOF
Comboboxname.AddItem rsTemp(Fieldname)
rsTemp.MoveNext
Loop
rsTemp.Close
Set rsTemp = Nothing
Comboboxname.ListIndex = 0
ado.Close
Set ado = Nothing
End Sub
This code helps u to fill any combobox. One routine fits all Comments
No comments yet — be the first to post one!
Post a Comment