473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Code To Check a Folder For any Files

Access 2000

I need to check a particular folder for files of a particular type
(such as *.txt) Prior to the next step. If Files of said type are
present, then the code will continue, else it would stop & give the
user a warning & exit.

The file check is the part I am having trouble with, I don't know
where to start.

Any & ALL help truly appreciated!

Dale
Nov 13 '05 #1
5 2763
Dale Ring wrote:
Access 2000

I need to check a particular folder for files of a particular type
(such as *.txt) Prior to the next step. If Files of said type are
present, then the code will continue, else it would stop & give the
user a warning & exit.

The file check is the part I am having trouble with, I don't know
where to start.

Any & ALL help truly appreciated!

Dale


Check out the Dir() function. Something like this:

Public Sub processFolder(sPath As String)
Dim sFileName As String, nID As Long

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.txt", vbNormal)
Do While Len(sFileName) & vbNullString > 0
'<do some processing here>
sFileName = Dir()
Loop

End If

End Sub

--
'-------------------------------
' John Mishefske
'-------------------------------

Nov 13 '05 #2
There may be several files of several different types in the folder.

All I want to know is: Is the folder empty? Yes or No

From that point I can decide what I want the code to do next.

Dale

John Mishefske <mi****@execpc.com> wrote in message news:<10*************@corp.supernews.com>...
Dale Ring wrote:
Access 2000

I need to check a particular folder for files of a particular type
(such as *.txt) Prior to the next step. If Files of said type are
present, then the code will continue, else it would stop & give the
user a warning & exit.

The file check is the part I am having trouble with, I don't know
where to start.

Any & ALL help truly appreciated!

Dale


Check out the Dir() function. Something like this:

Public Sub processFolder(sPath As String)
Dim sFileName As String, nID As Long

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.txt", vbNormal)
Do While Len(sFileName) & vbNullString > 0
'<do some processing here>
sFileName = Dir()
Loop

End If

End Sub

Nov 13 '05 #3
mt****@yadtel.net (Dale Ring) wrote in message news:<d5*************************@posting.google.c om>...
There may be several files of several different types in the folder.

All I want to know is: Is the folder empty? Yes or No


<SNIP>
Check out the Dir() function. Something like this:

Public Sub processFolder(sPath As String)
Dim sFileName As String, nID As Long

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.txt", vbNormal)
Do While Len(sFileName) & vbNullString > 0
'<do some processing here>
sFileName = Dir()
Loop

End If

End Sub

So make the sub a function.

This worked for me... your mileage may vary. You'll need the
BrowseFolder API from www.mpvs.org from the API section.

Option Compare Database
Option Explicit

Private Sub Command0_Click()
Dim sPath As String

sPath = BrowseFolder("What Folder you want to select?")
Me.txtFolder = sPath

MsgBox "Path: " & sPath & " empty: " & IsEmptyFolder(sPath)
End Sub

Public Function IsEmptyFolder(ByVal sPath As String) As Boolean
Dim sFileName As String, nID As Long

IsEmptyFolder = True

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.*", vbNormal)
IsEmptyFolder = (Len(sFileName) & vbNullString = 0)
End If
End Function
Nov 13 '05 #4
mt****@yadtel.net (Dale Ring) wrote in message news:<d5*************************@posting.google.c om>...
There may be several files of several different types in the folder.

All I want to know is: Is the folder empty? Yes or No


<SNIP>
Check out the Dir() function. Something like this:

Public Sub processFolder(sPath As String)
Dim sFileName As String, nID As Long

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.txt", vbNormal)
Do While Len(sFileName) & vbNullString > 0
'<do some processing here>
sFileName = Dir()
Loop

End If

End Sub

So make the sub a function.

This worked for me... your mileage may vary. You'll need the
BrowseFolder API from www.mpvs.org from the API section.

Option Compare Database
Option Explicit

Private Sub Command0_Click()
Dim sPath As String

sPath = BrowseFolder("What Folder you want to select?")
Me.txtFolder = sPath

MsgBox "Path: " & sPath & " empty: " & IsEmptyFolder(sPath)
End Sub

Public Function IsEmptyFolder(ByVal sPath As String) As Boolean
Dim sFileName As String, nID As Long

IsEmptyFolder = True

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.*", vbNormal)
IsEmptyFolder = (Len(sFileName) & vbNullString = 0)
End If
End Function
Nov 13 '05 #5
mt****@yadtel.net (Dale Ring) wrote in message news:<d5*************************@posting.google.c om>...
There may be several files of several different types in the folder.

All I want to know is: Is the folder empty? Yes or No


<SNIP>
Check out the Dir() function. Something like this:

Public Sub processFolder(sPath As String)
Dim sFileName As String, nID As Long

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.txt", vbNormal)
Do While Len(sFileName) & vbNullString > 0
'<do some processing here>
sFileName = Dir()
Loop

End If

End Sub

So make the sub a function.

This worked for me... your mileage may vary. You'll need the
BrowseFolder API from www.mpvs.org from the API section.

Option Compare Database
Option Explicit

Private Sub Command0_Click()
Dim sPath As String

sPath = BrowseFolder("What Folder you want to select?")
Me.txtFolder = sPath

MsgBox "Path: " & sPath & " empty: " & IsEmptyFolder(sPath)
End Sub

Public Function IsEmptyFolder(ByVal sPath As String) As Boolean
Dim sFileName As String, nID As Long

IsEmptyFolder = True

If Len(Dir(sPath, vbDirectory)) & vbNullString > 0 Then
sFileName = Dir(sPath & "\*.*", vbNormal)
IsEmptyFolder = (Len(sFileName) & vbNullString = 0)
End If
End Function
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Christopher Brandsdal | last post by:
Hi! I have a problem running my code on 2000 server and iis5.0. The code runs perfectly on my localhost (xp iis5.1) but when i run it on 2000 server iis5.0 I get this error: ...
1
by: Joe | last post by:
I made a template for webforms. The template.inf calls for two files the ..ascx and the .cs. The .cs template file's code does not get written out to the newly added control? Joe
7
by: tgh003 | last post by:
I would be interested to hear how others are managing their javascript (.js) files from the original code vs the obfuscated version they publish to their site/webapp. I currently manage 2 files,...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
7
by: Alan Silver | last post by:
Hello, I am just looking at VWD and seeing what needs doing to take an existing site I've written by hand and importing it into VWD. I've already discovered that I need to rename my code-behind...
2
by: Carlo \(MCP only\) | last post by:
Hi to all I'm askyng you a suggestion about the best way to share the same source code between VS2003 and VS2005. The project I'm developing is a controls and components library, and the...
3
by: tshad | last post by:
Is there some way to have the fileWatcher to initially check the folder to see if there is anything in it (based on the filters)? If I reboot the machine, for example, and it starts up the...
8
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I have some code (given to me), but I don't know alot about ASP, so I was hoping someone here can help. Running on Win 2008 server. The code below will scan a folder and subfolder...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.