Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Posts
    24

    Question Unanswered: Existence of a table in a database

    Hi everyone,
    My problem may seem easy but still I couldn't find a proper solution. Here it is:

    I want to dynamically update a database A with the records of the tables of another old one, let's call it B. What could happen is that A has some tables that B don't have. In this case I shouldn't try to run the Insert SQL query which raises an error...

    And that's my problem, I don't know how to check whether a table in A exists in B...

    Thanks in advance for your help

  2. #2
    Join Date
    Feb 2003
    Posts
    24

    Thumbs down

    I've found a crap way to solve this. I loop in the names of thetables of the old database and check if any of them matches the name of the current table of the new database I'm working on.
    I'm sure there's a more efficient way, though. Let me know if you have any better idea...

    THX

  3. #3
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122

    Re: Existence of a table in a database

    Originally posted by thorgnole
    Hi everyone,
    My problem may seem easy but still I couldn't find a proper solution. Here it is:

    I want to dynamically update a database A with the records of the tables of another old one, let's call it B. What could happen is that A has some tables that B don't have. In this case I shouldn't try to run the Insert SQL query which raises an error...

    And that's my problem, I don't know how to check whether a table in A exists in B...

    Thanks in advance for your help
    Why don't you use
    On Error Resume Next

    That looks like what you need. If an error occurs, it just moves to the next statement...

    Dan

  4. #4
    Join Date
    Feb 2003
    Posts
    24

    Smile

    It's a god idea, thx DannyY... But I'd rather not raise this error at all...

  5. #5
    Join Date
    Feb 2003
    Posts
    24

    Lightbulb

    FAO anyone interested:

    For Each tdfLoopOld In dbsOld.TableDefs
    If (tdfLoopOld.Name = tdfLoopLocal.Name) Then
    exists = True
    Exit For
    End If
    Next tdfLoopOld

Posting Permissions

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