Hi, I am trying to get a combobox on a form to be populated by a recordset. I am using the following code, but always get a "Type Mismatch" error on the "cboSiteName.RowSource = rsSite" line.
What am I doing wrong?
Thanks for the help!
Dim cnn As ADODB.Connection
Dim rsSite As ADODB.Recordset
'Create the connection.
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\DatabaseBE.mdb;"
'Create recordset reference and set its properties.
Set rsSite = New ADODB.Recordset
With rsSite
Set .ActiveConnection = cnn
.Source = "SELECT SiteName from tblSite"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
'Set the combobox rowsource to the ADO recordset
cboSiteName.RowSource = rsSite
'Close the recordset and connection
Set rsSite = Nothing
Set cnn = Nothing
What am I doing wrong?
Thanks for the help!
Dim cnn As ADODB.Connection
Dim rsSite As ADODB.Recordset
'Create the connection.
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\DatabaseBE.mdb;"
'Create recordset reference and set its properties.
Set rsSite = New ADODB.Recordset
With rsSite
Set .ActiveConnection = cnn
.Source = "SELECT SiteName from tblSite"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
'Set the combobox rowsource to the ADO recordset
cboSiteName.RowSource = rsSite
'Close the recordset and connection
Set rsSite = Nothing
Set cnn = Nothing