schmir1
asked on
DAO to ADO Tabledef Code
I need to convert some DAO code to ADO. How do I access tabledef info? Below is how I did it using DAO:
Private Sub cboTables_Enter()
Dim tdf As TableDef
Dim strOutput As String
dbMCL.TableDefs.Refresh
For Each tdf In dbMCL.TableDefs
strOutput = strOutput & ";" & tdf.Name
Next tdf
strOutput = Mid(strOutput, 2)
Me.cboTables.RowSource = strOutput
End Sub
Private Sub cboTables_Enter()
Dim tdf As TableDef
Dim strOutput As String
dbMCL.TableDefs.Refresh
For Each tdf In dbMCL.TableDefs
strOutput = strOutput & ";" & tdf.Name
Next tdf
strOutput = Mid(strOutput, 2)
Me.cboTables.RowSource = strOutput
End Sub
Use this as a query and then act upon the recordset: select * from information_schema.tables
ASKER
I'm afraid I don't understand your answer.
I did find a way to do what I want using AccessObject as follows:
Private Sub cboTables_Enter()
'List all tables in the tables section
Dim strOutput As String
Dim obj As AccessObject
Dim dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
'Filter out the system tables
If InStr(1, obj.Name, "sys", vbTextCompare) = 0 Then
strOutput = strOutput & ";" & obj.Name
End If
Next obj
strOutput = Mid(strOutput, 2)
Me!cboTables.RowSource = strOutput
End Sub
I did find a way to do what I want using AccessObject as follows:
Private Sub cboTables_Enter()
'List all tables in the tables section
Dim strOutput As String
Dim obj As AccessObject
Dim dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
'Filter out the system tables
If InStr(1, obj.Name, "sys", vbTextCompare) = 0 Then
strOutput = strOutput & ";" & obj.Name
End If
Next obj
strOutput = Mid(strOutput, 2)
Me!cboTables.RowSource = strOutput
End Sub
I guess I didn't understand your question then--do you not want to get away from Access objects and use ADO?
ASKER
Looks like Access Objects work with SQL. Does your way have advantages? If so, can you give me more detail as to how I would use it (understanding that I don't know anything about information_schema.tables
ASKER
arbert
Do you have any farther input? It will probably be useful to me to understand your answer (and exept it as an answer) even if I don't use it in this particular case.
You wouldn't know anything about replication(-:. I've have opened another question just begging for an answer.
Do you have any farther input? It will probably be useful to me to understand your answer (and exept it as an answer) even if I don't use it in this particular case.
You wouldn't know anything about replication(-:. I've have opened another question just begging for an answer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.