Results 1 to 4 of 4

Thread: How do I...?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Philippines
    Posts
    5

    Question

    Is there a function in DAO 3.51 that checks whether a certain table name exist in a database (MDB) file without looping at each table?

    Please help.

    jade

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    You can use a sql statment and use one of the hidden tables in access (MSysObjects)

    eg. "SELECT name FROM MSysObjects WHERE name = '" & your table & "'"

    This will return any objects that are in your database.

    Hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb TableDefs

    How about the TableDefs?
    Code:
    Private Form_Load()
    Dim z%
    Dim MyDb As DAO.Database
    Set MyDb = DBEngine.WorkSpace(0).OpenDatabase("<Your Database.",False,False)
    'Set AllTableDefs to definitions of all tables in the database:
    Set AllTableDefs = MyDb.TableDefs
    "Check for Table
    For z = 0 To AllTableDefs.Count - 1
        If StrComp(AllTableDefs(z).Name,"<Your Table Name.",vbBinaryCompare) = 0 then
        Msgbox "Table Found!",vbInformation + vbOkOnly
        Exit Sub
    Next
    End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Philippines
    Posts
    5

    Wink

    Thanks Ianpbaker.

    It worked. Again thanks a lot.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width