XLEAccessGuru
XLEGuru
- Local time
- Today, 14:03
- Joined
- Nov 17, 2006
- Messages
- 65
Hi folks,
I have a procedure written as shown below. When I try to call it from a button click event on a form, I get "Argument Not Optional". What needs adjusted in the procedure to fix that? Any help appreciated. Urgent issue! THANKS!!!
I have a procedure written as shown below. When I try to call it from a button click event on a form, I get "Argument Not Optional". What needs adjusted in the procedure to fix that? Any help appreciated. Urgent issue! THANKS!!!
Code:
Public Sub GetFileNames(FolderSpec As String)
' Returns a list of filenames and filesizes that are present in folderSpec
' Requires that "Microsoft Scripting Runtime" be referenced by the application
Dim fso As New Scripting.FileSystemObject
Dim fd As Scripting.Folder
Dim f As Scripting.File
Dim fns As String
Dim rec As Recordset
SetWarnings = False
'set recordset
Set rec = CurrentDb.OpenRecordset("tblImportLog", dbOpenDynaset)
'get a folder object
Set fd = fso.GetFolder(FolderSpec)
'traverse the files collection of the folder
For Each f In fd.Files
'return information about the file and assign to string
fns = "C:\" & fns & f.Name
With rec
.AddNew
!Date = Now()
!FileName = fns
.Update
End With
Next f
'assign to function
End Sub