From DAO to ADO???

Matt_Hirst

Access Numpty
Local time
Today, 15:19
Joined
Nov 25, 2006
Messages
15
Hi,

I have a form with a drive list box, directory list box, file list box and two other list boxes.

The file list boxes bring up names of .mdb files found in the directory. What I want to do is populate the first list box with the tables held within the file selected by the file list box, then for whatever table I select it should populate the second list box with the fields for the table.

I have used the following code, DAO, but am now trying to re-write it using ADO what am I doing wrong?

Sub File1_Click()
' If a file is selected this procedure populates the tables list, List1, with a list of tables held
' Dim mytabledef As TableDef

clear_form

Set objAccessConnection = New ADODB.Connection
Set rsAccess = New ADODB.Recordset

'open connection to server
objAccessConnection.ConnectionString = "provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & File1.Path & "\" & File1.FileName
objAccessConnection.Open

'Set objdb = OpenDatabase(Dir1.Path & "\" & File1.FileName, True, False)

'For Each mytabledef In objdb.TableDefs() ' For each table in database
'List1.AddItem mytabledef.Name ' Add tables name to list box 1
'Next mytabledef

End Sub

P.S. You can see where I have commented out the DAO code
 

Users who are viewing this thread

Back
Top Bottom