I am using the AllenBrowne code of "filldirlisttot able" to provide some functions for a media library manager I am building in access 2003.
I have four checkboxes which if all four are not turned on, give a list of extensions that should be search for. However, when I do it that way, I get no results.
The code works great. Only one issue, I cannot find anywhere on the net any notes about using the filespec option.
By default it uses *.*, and I can make it work by specifying only one extension, such as *.jpg, but it becomes useless when I specify multiple extensions such as *.jpg, *.gif, *.png.
Obviously that must be the wrong way to provide the filespec.
Has anyone used this function? I am providing part of it below.
There may even be a better way of doing this, but I have written substantial code around this so I thought I would see if nybody was familiar with it before I started working on a different solution.
I am kind of thinking that unless this code simply cannot handle the multiple extensions regardless of how they are provided, then I may have to re-write this section of code.
This goes to:
Any help or suggestions are appreciated.
I have four checkboxes which if all four are not turned on, give a list of extensions that should be search for. However, when I do it that way, I get no results.
The code works great. Only one issue, I cannot find anywhere on the net any notes about using the filespec option.
By default it uses *.*, and I can make it work by specifying only one extension, such as *.jpg, but it becomes useless when I specify multiple extensions such as *.jpg, *.gif, *.png.
Obviously that must be the wrong way to provide the filespec.
Has anyone used this function? I am providing part of it below.
There may even be a better way of doing this, but I have written substantial code around this so I thought I would see if nybody was familiar with it before I started working on a different solution.
I am kind of thinking that unless this code simply cannot handle the multiple extensions regardless of how they are provided, then I may have to re-write this section of code.
Code:
Call FillDirToTable(colDirList, strpath, strFileSpec, bIncludeSubfolders)
Code:
Private Function FillDirToTable(colDirList As Collection _ , ByVal strFolder As String _ , strFileSpec As String _ , bIncludeSubfolders As Boolean) 'Build up a list of files, and then add add to this list, any additional folders On Error GoTo Err_Handler Dim strTemp As String Dim colFolders As New Collection Dim vFolderName As Variant Dim strSQL As String 'Add the files to the folder. strFolder = TrailingSlash(strFolder) strTemp = Dir(strFolder & strFileSpec) Do While strTemp <> vbNullString gCount = gCount + 1 SysCmd acSysCmdSetStatus, gCount strSQL = "INSERT INTO zzLibScan " _ & " (MediaFileName, MediaPath) " _ & " SELECT """ & strTemp & """" _ & ", """ & strFolder & """;" CurrentDb.Execute strSQL colDirList.Add strFolder & strTemp strTemp = Dir Loop If bIncludeSubfolders Then 'Build collection of additional subfolders. strTemp = Dir(strFolder, vbDirectory) Do While strTemp <> vbNullString If (strTemp <> ".") And (strTemp <> "..") Then If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0& Then colFolders.Add strTemp End If End If strTemp = Dir Loop 'Call function recursively for each subfolder. For Each vFolderName In colFolders Call FillDirToTable(colDirList, strFolder & TrailingSlash(vFolderName), strFileSpec, True) Next vFolderName End If Exit_Handler: Exit Function Err_Handler: strSQL = "INSERT INTO zzLibScan " _ & " (MediaFileName, MediaPath) " _ & " SELECT "" ~~~ ERROR ~~~""" _ & ", """ & strFolder & """;" CurrentDb.Execute strSQL Resume Exit_Handler End Function Public Function TrailingSlash(varIn As Variant) As String If Len(varIn) > 0& Then If Right(varIn, 1&) = "\" Then TrailingSlash = varIn Else TrailingSlash = varIn & "\" End If End If End Function
Comment