This problem is driving me crazy.
Im using Access2003.
Basically what I wish to do is create a new record for each jpg bmp or gif
file in the current directory.
I need to just save the path and filename of each file in a table in its own
I am trying to do a DOS command to do a DIR of jpg, bmp and gif files, and
save the output to a file C:\Filelist.txt
using the following line.
Shell (Environ$("COMSPEC") & " /c Dir *.jpg *.bmp *.gif /S /B >
I then try to read that file into the Imagepath field with VBA doing the
Dim Q as string
Open "C:\Filelist.txt" For Input As #1
While Not EOF(1)
DoCmd.GoToRecord , , acNewRec
Line Input #1, Q
Imagepath = Q
Works OK first time used, creates a set of new records, one for each jpg bmp
and gif file in the directory. Bewdy.
But on second and subsequent uses (and a change of the current directory) it
creates a duplicate of the previously created set of records instead of the
contents of C:\Filelist.txt (ie Pass1 creates records OK, Pass2 creates same
records as Pass1, Pass3 creates same records as pass2 etc)
I checked C:\Filelist.txt and it has been created successfully each time
Yet VBA reads its contents incorrectly. Seems to ignore the fact that
C:\Filelist.txt has been overwritten.Always seems to
be one pass behind.
I have even tried using a macro to import C:\Filelist.txt as a table and do
an append query but same problem.
The behaviour of C:\Filelist.txt is odd.
Any help would be extremely appreciated.