Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    139

    Unanswered: checking to see if file exits

    I'm using this to check to see if file exists:

    If Dir("T:\SQLDATA\Order_Header.txt") <> "" Then

    "Do this...commands go here"

    Else
    MsgBox "Order Header does not exist, try again in 5 minutes"
    DoCmd.Quit

    End If

    It works fine to check for one file, but I need to check for 5 or so. Can anyone recommend an approach?
    Thanks,
    Bill

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    If this method works for one file, use a boolean variable and iterate through all of the required conditions. If at any point during the iterations your condition fails, set your boolean variable. Check the variable at the end of the code and act accordingly.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Or you can use an array putting all your file names in it, loop through it checking for the existence of the files.

  4. #4
    Join Date
    Mar 2004
    Location
    Oakland, CA, USA
    Posts
    26

    RE: check if file exists

    Hello Beeyule,

    Try this. It will loop thru the folder for your txt file.

    '----------------
    Dim tmpFile As String
    Dim tmpPath As String
    tmpPath = "T:\SQLDATA\"
    tmpFile = Dir(tmpPath & "*.txt")
    Do While tmpFile <> ""

    'Do this... commands go here

    tmpFile = Dir
    Loop
    '----------------

Posting Permissions

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