Need to get a list of jpeg files in a folder in order to create a one to one set of records in a table.
Examining the contents of a folder in Acess 2003
Collapse
X
-
Tags: None
-
Hi
You will need to use the Dir() function recursively.
[CODE=vb] Dim strNextFile As String
Dim strPath as String
'set path to folder and to look for jpg files
strPath = "C:\MyFolder\*. jpg"
'initialise Dir() function and get first filename
strNextFile = Dir(strPath, vbNormal)
'turn off warnings
Application.Set Option "Confirm Action Queries", False
'now loop using the Dir function until no more files found
Do While strNextFile <> ""
'insert filename into table tblJPES
DoCmd.RunSQL "INSERT INTO tblJPEGS (FilNam) Values (" & strNextFile & ");"
'now call Dir recursively
strNextFile = Dir
Loop
'turn warnings on
Application.Set Option "Confirm Action Queries", False
[/CODE]
I have assumed the file names will be written to field FilNam in table tblJPEGS.
Hope this helps
S7 -
-
[
Your welcome.
There are other ways to save the retrieved data using Recordsets and the like but I think that looping through the files of the folder and reading the contents is the issue here.
Good luck with the rest of your program.
S7Comment
Comment