Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to see if file exists on network drive

Status
Not open for further replies.

thefourthwall

IS-IT--Management
Feb 26, 2002
387
US
My search took me to this thread which details how to search for whether a folder exists (or not) on a network drive.

But I am need to check for a specific file rather than a folder, and to then have the macro called "update" not run if the file(s) aren't in the proper folder.

The macro someone else wrote, and it's a string of RunSQL actions which deletes table data and recreates it by importing ten text files all in the same network folder.

It's been two or three years since I was doing vbscript that dealt with folders & files. I'm very rusty here and could use some help.

 
If dir(\\drive\filepath\filename)>"" then
run macro
end if
 
Duane,

Again I was making things too complicated ... trying this now.Thank you.
 
Perhaps I was asking the wrong way; if the file does notexist, then run docmd.cancelevent else, and then loop to the next step of checking for the next file, etc.

Have tried if isnull, if not, etc., with Dir but continue getting syntax errors.

Thanks,
 
Something like this ?
Code:
If Dir("\\shareddir\dirpath\filename") = "" Then
   DoCmd.[i]WhatYouWant[/i]
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yeah, that makes sense. I changed the code to
Code:
If Dir("\\Fs-h361-m232\ISdfs$\Share\IS\WSU\Administrative\Cell_Phone_Database\sandbox\tempfiles\EID.txt") = "" Then
    DoCmd.Close acMacro, "copyofupdate", acSaveNo
End If
This code is in a function called by a runcode statement in a macro called "Update."

I want the macro to stop if the file eid.txt (among others) is missing. I renamed the file on purpose and ran the macro hoping that it would halt, or stop, but it kept on running. What am I doing wrong?
 
I'd be happy to do it all in vba... didn't occur to me to save the macro as a module; will try that now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top