M
Mike
I have the following module which reads all the names of a specified
folder into a table. I would like to also get the file size of those
files into a new column in my table. So far I found the filelen
function, but I don't know where to put the command in the module and
how to get the module to insert the size in the same table as the
filenames.
Any help appreciated. Thanks.
Here's the module I'm using:
Option Compare Database
Function LocateFile(strFileName As String)
Dim vItem As Variant
Dim db As DAO.Database
Dim strsourcefilepath As String
Dim Mysize
strsourcefilepath = DLookup("[source]", "filepath")
Set db = CurrentDb
With Application.FileSearch
.Filename = strFileName
.LookIn = strsourcefilepath
.SearchSubFolders = True
.Execute
CurrentDb.Execute "DELETE * from Import_songs_tbl",
dbFailOnError
For Each vItem In .FoundFiles
db.Execute _
"INSERT INTO Import_songs_tbl (Filename) " & _
"VALUES(" & Chr(34) & vItem & Chr(34) & ")", _
dbFailOnError
Next vItem
End With
MsgBox "Done.", vbInformation
Set db = Nothing
End Function
folder into a table. I would like to also get the file size of those
files into a new column in my table. So far I found the filelen
function, but I don't know where to put the command in the module and
how to get the module to insert the size in the same table as the
filenames.
Any help appreciated. Thanks.
Here's the module I'm using:
Option Compare Database
Function LocateFile(strFileName As String)
Dim vItem As Variant
Dim db As DAO.Database
Dim strsourcefilepath As String
Dim Mysize
strsourcefilepath = DLookup("[source]", "filepath")
Set db = CurrentDb
With Application.FileSearch
.Filename = strFileName
.LookIn = strsourcefilepath
.SearchSubFolders = True
.Execute
CurrentDb.Execute "DELETE * from Import_songs_tbl",
dbFailOnError
For Each vItem In .FoundFiles
db.Execute _
"INSERT INTO Import_songs_tbl (Filename) " & _
"VALUES(" & Chr(34) & vItem & Chr(34) & ")", _
dbFailOnError
Next vItem
End With
MsgBox "Done.", vbInformation
Set db = Nothing
End Function