Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740

    Unanswered: how to tell if a table exists

    i'm in $#it with a deadline and my brain doesn't work.

    i need to delete a table ...which is pretty simple:
    dim dab as database
    set dab = currentdb
    dab.tabledefs.delete "thisTable"

    but how do i tell if the table is there before i try to delete?

    this is hands-off stuff and i can't afford an error message.


    izy

  2. #2
    Join Date
    Jan 2003
    Posts
    3

    Re: how to tell if a table exists

    Originally posted by izyrider
    i'm in $#it with a deadline and my brain doesn't work.

    i need to delete a table ...which is pretty simple:
    dim dab as database
    set dab = currentdb
    dab.tabledefs.delete "thisTable"

    but how do i tell if the table is there before i try to delete?

    this is hands-off stuff and i can't afford an error message.


    izy

    I found some code from The Access Web that will help you.
    Website=http://www.mvps.org/access/

    '******************** Code Start ************************
    ' This code was originally written by Dev Ashish.
    ' It is not to be altered or distributed,
    ' except as part of an application.
    ' You are free to use it in any application,
    ' provided the copyright notice is left unchanged.
    '
    ' Code Courtesy of
    ' Dev Ashish
    '
    '
    Function fExistTable(strTableName As String) As Integer
    Dim db As Database
    Dim i As Integer
    Set db = DBEngine.Workspaces(0).Databases(0)
    fExistTable = False
    db.TableDefs.Refresh
    For i = 0 To db.TableDefs.Count - 1
    If strTableName = db.TableDefs(i).Name Then
    'Table Exists
    fExistTable = True
    Exit For
    End If
    Next i
    Set db = Nothing
    End Function
    '******************** Code End ************************

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    thanks MeanGene
    ...looks like a good scheme.


    izy

Posting Permissions

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