Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Test for file exists (Access 2000)

    Prior to opening a file (in my case a jpg image), I need to verify that it exists and if not then present an error message. What code do you use to test for the existance of a file assuming you have a variable with the entire filespec?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Test for file exists (Access 2000)

    You can use Dir to test if the file exists. Dir returns just the filename if the file exists, and returns a zero length string if it doesn't.

    If filename holds the full path and filename, then

    Dim strfilename as string
    strfilename = dir(filename)

    if strfilename = "" then
    file does not exist
    else
    strfilename holds just the filename
    end if
    Regards
    John



  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Test for file exists (Access 2000)

    Thanks. That works.

Posting Permissions

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