|
|

Counting The Number Of Files In A Directory
Normally, when doing file handling from within Access, you do not need to know the number of files within a directory, you merely loop through each file until there are no more left. However, if you wish to count the files, you will need to use a function such as this:
Function fCountFilesInDir(strDir As String, Optional varFileType As Variant) As Long
On Error GoTo E_Handle
Dim strFile As String
Dim lngCount As Long
strFile = Dir(strDir, vbNormal)
Do While strFile <> ""
If Not IsMissing(varFileType) Then
If Right(strFile, Len(varFileType)) = varFileType Then lngCount = lngCount + 1
Else
lngCount = lngCount + 1
End If
strFile = Dir
Loop
fCountFilesInDir = lngCount
fExit:
Exit Function
E_Handle:
MsgBox Err.Description, vbOKOnly + vbCritical, "Error: " & Err.Number
Resume fExit
End Function
|
Top
HOME |
NEW |
TABLES |
QUERIES |
FORMS |
REPORTS |
GENERAL |
API |
DOWNLOADS |
TUTORIAL |
RESOURCES
E-MAIL
Copyright & Disclaimer
|
| |