This code selects two columns, a key and a column respectively. The
key is shown in the combo's first (hidden) column, the data in its
second (visible) column. I've used appropriate recordset settings in
case you want to be able to update the source.
'-----------------------
Option Explicit
Private Sub UserForm_Initialize()
Dim m_oConn As Object
Dim m_oRS As Object
Const strCONNECTION As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="
Const strPATH As String = "C:\Tempo\New_Jet_DB.mdb"
Const strSQL As String = "SELECT RefID, Surname FROM PersonalDetails"
Dim vntArray As Variant
Set m_oConn = CreateObject("ADODB.Connection")
m_oConn.Open strCONNECTION & strPATH
Set m_oRS = CreateObject("ADODB.Recordset")
With m_oRS
.CursorLocation = 3 ' adUseClient
.CursorType = 3 ' adOpenStatic
.LockType = 4 ' adLockBatchOptimistic
.ActiveConnection = m_oConn
.Command = strSQL
.Open
End With
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.