Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    May 2002
    Location
    Auckland, North Island, New Zealand
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking an external file exists (XP)

    I am using the TransferDatabase command in a macro to link to tables in another database (eg two different companies), the path to each database being defined in a specific fields.
    If the table name currently exists, the TransferDatabase command links the new table with the same tablename and suffix 1. I need to replace the table, so am deleting the table first.
    However, if the database has been moved or deleted, the macro deletes all the current links, then cant find the new database and gives error message. But when I try to go back to the original database, the macro gives error message because the cannot delete the original links cause they have gone.
    I cannot figure out how I can do a check on the availability of the new database (or table) before the deletes begin. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>
    Can someone set me down the right path please.

    Thanks

    John

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Checking an external file exists (XP)

    Unfortunately you can't solve that problem with a macro as there is no error checking feature for macros, so you need to do your task using VBA. With VBA it is fairly easy to check to see whether a given table exists in a database, so you could put conditional logic in it to determine whether or not a given table exists, but you could also check to see if the 1 suffix version exists, and if it does simply rename it - that will automatically delete the original table link. But I don't see how you are going to solve the problem when the target database has been moved or deleted - I would think you would want user intervention at that point, and probably someone with helpdesk capability needs to be involved.
    Wendell

  3. #3
    Star Lounger
    Join Date
    May 2002
    Location
    Auckland, North Island, New Zealand
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checking an external file exists (XP)

    Wendell
    Thanks for confirming not possible in a macro.
    What I believe I need is to be able to validate that the new path/file exists before I run the macro. If Yes, run the macro, If No display a message saying "this {path/file} does not exist". But I don't know how to do this validation.
    Regards
    John

  4. #4
    Star Lounger
    Join Date
    Aug 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checking an external file exists (XP)

    You can check if a file exists with the following: (atemp is a string variable) and newcpath is the full path name of the file. If the file is found, it is deleted.

    atemp = ""
    atemp = dir(newcpath)
    If atemp <> "" Then Kill newcpath

    Cheers.

    Graeme.

Posting Permissions

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