Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Thanked 0 Times in 0 Posts

    Determine if Table is present (Access 97 SR-2)

    I have a form that allows users to import tables from other databases. Before continuing with additional code, I want to ensure that they imported the correct tables. Is there a way to check, using code, if a table is contained within the database?

  2. #2

    Re: Determine if Table is present (Access 97 SR-2)

    If you know the table names you expect, you can scroll through the TableDefs collection and look for a match.

    Dim db as Database, tDef as TableDef
    Dim x as Integer, boolFound as Boolean
    Set db = CurrentDb
    for x = 0 To db.TableDefs.Count -1
    Set tDef = db.TableDefs(x)
    If tDef.Name = "MyTable" Then
    boolFound = True
    Exit Sub
    End If
    Next x

    then use the boolFound value (True or False) to determine your action.

Posting Permissions

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