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!

Dir function problems

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I am trying to find all files in a directory form within Access2003 using code. I use the following Dir method.

strFile1 = Dir(FileLoc) ' & " \*.*")

When I check the name stFile1 is set to nothing when there are in fact two file in the directory. I have tried replacing the variable FileLoc with the actual path ("C:\Program Files\Directory 1"). I have also eliminated the *.* both with the same result, strFile1 = Nothing.
Where did I go wrong? Thanks.


 
Why the single quote before the "and" character?
I use Dir(pathname, vbDirectory) all the time and works OK.
In your example, strFile1 = Dir(FileLoc) ' & " \*.*")
you also have an unmatched (and unneeded) closing paren after FileLoc. Maybe try strFile1 = Dir(FileLoc & " \*.*")?

I have great faith in fools; self-confidence my friends call it.
-Poe
 
genomon is correct, if your just looking for,
existence of one file.
To begin a search on all files,

strFile = Dir(FileLoc & "\")
Debug.Print strFile
Do Until strFile = ""
strFile = Dir()
Debug.Print strFile
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top