By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

Dir$ command

P: n/a
ARC
Hello,

I use the following code to check to see if a folder exists. The problem is,
if the folder does exist, but it's empty, the following code still activates
telling the user the folder doesn't exist. Can anyone suggest a better way
to see if the folder is there, whether or not it's empty or not? Many
Thanks!

If Not IsNull(Me!FilesStoreFolder) Then
Dim CopyStoreExists As Variant
CopyStoreExists = Dir(Me!FilesStoreFolder)
If CopyStoreExists = "" Then
MsgBox "The customer store folder: " & Me!FilesStoreFolder &
" does not exist." , vbCritical
End If
End If
May 10 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Thu, 10 May 2007 19:55:08 GMT, "ARC" <an**@andyc.comwrote:

Rather than having the user type a folder in a text box, use the
BrowseFolder dialog:
http://www.mvps.org/access/api/api0002.htm

If you badly want to do your thing, write this:
Dir(Me!FilesStoreFolder, vbDirectory)

-Tom.

>Hello,

I use the following code to check to see if a folder exists. The problem is,
if the folder does exist, but it's empty, the following code still activates
telling the user the folder doesn't exist. Can anyone suggest a better way
to see if the folder is there, whether or not it's empty or not? Many
Thanks!

If Not IsNull(Me!FilesStoreFolder) Then
Dim CopyStoreExists As Variant
CopyStoreExists = Dir(Me!FilesStoreFolder)
If CopyStoreExists = "" Then
MsgBox "The customer store folder: " & Me!FilesStoreFolder &
" does not exist." , vbCritical
End If
End If
May 11 '07 #2

P: n/a
ARC
I'm already using the browse folder dialgue... I just had to put in
error-code to make sure that the directory was actually there... Sometimes
user's may use the db on a different machine that may not have the specified
folder. So I wrote the error checking code below, but if the folder is empty
, it still triggers my error code (even though they actually have the folder
on their hard drive).

"Tom van Stiphout" <no*************@cox.netwrote in message
news:lc********************************@4ax.com...
On Thu, 10 May 2007 19:55:08 GMT, "ARC" <an**@andyc.comwrote:

Rather than having the user type a folder in a text box, use the
BrowseFolder dialog:
http://www.mvps.org/access/api/api0002.htm

If you badly want to do your thing, write this:
Dir(Me!FilesStoreFolder, vbDirectory)

-Tom.

>>Hello,

I use the following code to check to see if a folder exists. The problem
is,
if the folder does exist, but it's empty, the following code still
activates
telling the user the folder doesn't exist. Can anyone suggest a better way
to see if the folder is there, whether or not it's empty or not? Many
Thanks!

If Not IsNull(Me!FilesStoreFolder) Then
Dim CopyStoreExists As Variant
CopyStoreExists = Dir(Me!FilesStoreFolder)
If CopyStoreExists = "" Then
MsgBox "The customer store folder: " & Me!FilesStoreFolder
&
" does not exist." , vbCritical
End If
End If

May 11 '07 #3

P: n/a
ARC
Excellent!! I just tried your code and it works a charm! Now it returns "."
if there are no files in the folder. But at least I know the folder is
there...

Many Thanks for your help, Tom.

Andy
"Tom van Stiphout" <no*************@cox.netwrote in message
news:lc********************************@4ax.com...
On Thu, 10 May 2007 19:55:08 GMT, "ARC" <an**@andyc.comwrote:

Rather than having the user type a folder in a text box, use the
BrowseFolder dialog:
http://www.mvps.org/access/api/api0002.htm

If you badly want to do your thing, write this:
Dir(Me!FilesStoreFolder, vbDirectory)

-Tom.

>>Hello,

I use the following code to check to see if a folder exists. The problem
is,
if the folder does exist, but it's empty, the following code still
activates
telling the user the folder doesn't exist. Can anyone suggest a better way
to see if the folder is there, whether or not it's empty or not? Many
Thanks!

If Not IsNull(Me!FilesStoreFolder) Then
Dim CopyStoreExists As Variant
CopyStoreExists = Dir(Me!FilesStoreFolder)
If CopyStoreExists = "" Then
MsgBox "The customer store folder: " & Me!FilesStoreFolder
&
" does not exist." , vbCritical
End If
End If

May 11 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.