Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking if a folder already exists from access 4

Status
Not open for further replies.

frankis

Programmer
Sep 21, 2003
14
GB
Hi,
I am trying to check if a folder exists and then if it does I will open it using:

FollowHyperlink "\path\to\folder"

Otherwise I would like to create a new folder.

has anyone got any ideas how i should go about this?

many thanks
austin
 
Code:
If Dir ("C:\foldername", vbDirectory) <> "" Then
  ' Your folder exists
  FollowHyperlink "c:\folder"
Else
  MsgBox "Folder doesn't exist"
End If
 
A starting point:
strFolder = "\path\to\folder"
If Dir(strFolder, vbDirectory) = "" Then MkDir strFolder
FollowHyperlink strFolder

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Give this a whirl:
Code:
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolderPath = "Path/To/Folder"
On Error Resume Next
'Errors if the folder already exists
objFSO.CreateFolder strFolderPath
On Error GoTo 0
Set objFSO = Nothing

FollowHyperlink strFolderPath

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Using the Dir() function would be more efficient than using the FSO, although it probably depends on the scale and usage that would determine which is used. For a one-time use, I recommend the Dir(), for prolonged/extensive use I recommend the FSO.

-----------
Regards,
Zack Barresse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top