Counting The Number of Files In A Directory

  • Thread starter Thread starter Riyaz23
  • Start date Start date
R

Riyaz23

Hi,

I am trying to do the following and any help would be greatly
appreciated:

I'd like to have a form command button in ms access that has a on click
action to go and check a hard coded directory for a given number of
files. It sounds like a simple enough thing to do, but I am having
difficulties with it. Can this be done via VB code within access? If
so please help.

Thanks in Advance,
Riz
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

One way would be to use the Dir() function:

=== begin air code ===

Dim strSearch As String
Dim strTemp As String
Dim i As Integer

' Count all the .zip files in the directory My Documents
strSearch = "C:\My Documents\*.zip"

strTemp = Dir(strSearch)

Do While Len(strTemp) > 0
i = i + 1
strTemp = Dir
Loop

Debug.Print i & " .zip files in My Documents"

=== end air code ===

See the VBA Help article on Dir Function for more info.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ+J7vIechKqOuFEgEQIxMwCeNfWcZYAjwDGjtdPOrW/alvdpbTQAoNDS
etpuX75SZ6VImOwhjbyquJnh
=MXGW
-----END PGP SIGNATURE-----
 
Back
Top