chris-uk-lad
Registered User.
- Local time
- Today, 14:14
- Joined
- Jul 8, 2008
- Messages
- 271
I have a module created that will update a table(TEMP) with the names of folders stored in a file. I want this code to be ran once the access database is opened.
Ive tried Runcode in macros but it wont detect NewImages, any help would be appreciated
Code:
Public Sub NewImages()
Dim fso As FileSystemObject
Dim folder As folder
Dim f As Variant
Dim rs As DAO.Recordset
Dim strSQL As String
Dim subf As Variant
Dim f1 As Variant
Dim strString As String
Dim subf1 As Variant
Set fso = New FileSystemObject
Set folder = fso.GetFolder("c:\Images\")
Set rs = CurrentDb.OpenRecordset("SELECT * from TEMP WHERE SURNAME IS NULL")
' Set file = f.files
Set subf = folder.SubFolders
For Each subf1 In subf 'for all subfolders of the merge folder
Set f = subf1.Files 'f = files with subfolders
DoEvents
Debug.Print subf1.Name
For Each f1 In f
rs.AddNew
rs!Surname = Mid(subf1.Name, InStr(subf1.Name, "_") + 1, Len(subf1.Name))
rs!PAYREF = Mid(subf1.Name, 1, InStr(subf1.Name, "_") - 1)
rs!Date = f1.DateCreated
rs!Path = f1.Path
rs!FileName = f1.Name
rs.Update
Debug.Print f1.Name
Next
Next
End Sub
Ive tried Runcode in macros but it wont detect NewImages, any help would be appreciated