Re: Access 2000
According to the help, to loop through a folder, you use code like
this:
' Returns filename with specified extension. If more than one *.ini
' file exists, the first file found is returned.
MyFile = Dir("C:\WINDOWS\*.INI")
' Call Dir again without arguments to return the next *.INI file in
the
' same directory.
MyFile = Dir
--------------
ok...I'm trying something similar.
I am trying to loop through a folder and do something with each of the
4 .mdb files in the folder.
Whenever I add something in my loop, I get an "Invalid procedure call
or argument" error on this line: strOldFile = Dir
When I add the "FileExists" function, I need to do this to see if the
new file exists then if it does, delete the old one.
If I remove the "FileExists" line, the >>strOldFile = Dir<< line of
code works fine for all files in the loop.
I have tried this by adding an array of different lines of code, but
when I do, then the >>strOldFile = Dir<< line will always return
null on the 2nd try, and there are 4 files I need to look at in this
loop.
What good is this process......
MyFile = Dir("C:\WINDOWS\*.INI")
MyFile = Dir
.....when I cannot add anything to it?
--------
Here is my code:
strOldFile = Dir("C:\My Documents\*.mdb")
Do While strOldFile <> ""
strNewFile = Left$(strOldFile, (Len(strOldFile) - 4)) & "_CMPCT.MDB"
blnreturn = FileExists(strDirectory & strNewFile)
Debug.Print "Old File: " & strOldFile & " / " & "New File: " &
strNewFile
strOldFile = Dir
Loop
-------
Thanks for the assistance.
RLN