0

Hi..actually am stuck up at a place while converting my current projet from DAO to ADO. As there is no equivalent function for Tabledef in ADO..thus i cant figure it out, as to how to replace the following code with.

The following code searches for the table with name "BlockTable". If it finds the table, flag is set to TRUE, else False.

Dim tdf as TableDef

For Each tdf In db.TableDefs
If UCase(tdf.Name) = UCase("Blocktable") Then
l_flgtab = True
Exit For
Else
l_flgtab = False
End If
Next tdf

PLzzz help me out...

2
Contributors
2
Replies
9
Views
5 Years
Discussion Span
Last Post by frnds2vivek
0

You can use this code snippet to help you out:

Dim myConn As ADODB.Connection
Dim myRs As ADODB.Recordset
Set myConn = New ADODB.Connection
myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyDatabase.mdb;Persist Security Info=False"

Set myRs = myConn.OpenSchema(adSchemaTables)

If myRs.EOF = False Then
    Do
        Debug.Print myRs.Fields("TABLE_NAME").Value
        myRs.MoveNext
    Loop Until myRs.EOF = True
End If
myRs.Close
myConn.Close
Set myRs = Nothing
Set myConn = Nothing

Note that you'll have to be sure and change the connection string to point to the database you're interested in. Keep in mind too that this will also return the names of ALL the tables in your Access database (including the system tables) so you'll have to test inside the DO..LOOP construct and exit as appropriate.

Hope this helps! Good luck!

Edited by BitBlt: Formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.