'* arnelgp
'* In VBE, add reference to
'* Microsoft ActiveX Data Objects X.XX Library
'*
'* you must also save the document as macro-enabled (.docm)
'*
Private Sub Document_Open()
Dim DATA_PATH As String
Dim adoRS As ADODB.Recordset
Dim cnn As ADODB.Connection
DATA_PATH = "the path to your MS Access database, eg. "D:\MyFiles\SourceDatabase.accdb"
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; " & _
"Data Source = " & DATA_PATH & ";" & _
"Persist Security Info = False;"
cnn.Open
Set adoRS = New ADODB.Recordset
With adoRS
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
'.CursorType=adOpenStatic
.LockType = adLockOptimistic
.CursorType = adOpenStatic
'**
'** NOTE, i am using Table1 from the database and retriving the names from Names field
'**
.Open "SELECT [Names] From Table1;", cnn
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
Me.ComboBox1.AddItem !Names
.MoveNext
Wend
End With
Set adrs = Nothing
cnn.Close
Set cnn = Nothing
End Sub