Hi,
Can anyone help me with this?
I found this code but can't seem to get it to work.
Access file = PE_CG_list
Table = PE-GC-list
Column = PEs
I have the data source ending in .accdb because that's the path to the file although the original code said to put .mdb. When I put .mdb it says it can't find the file but with .accdb it says it doesn't know the database type.
I have references set to both ADO and Access.
Code:
Sub AutoOpen()
On Error GoTo Document_Open_Err
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=U:\TPCentral_Too\PE_GC_list.accdb"
.Open "SELECT [PEs] FROM PE-GC-list ORDER BY [PEs];", _
cnn, adOpenStatic
rst.MoveFirst
With ThisDocument.ComboBox1
.Clear
Do
.Add rst![PEs]
rst.MoveNext
Loop Until rst.EOF
End With
Document_Open_Exit:
On Error Resume Next
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
Document_Open_Err:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
Resume Document_Open_Exit
End Sub
Any help is appreciated - thank you!