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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for Directory

Status
Not open for further replies.

DLeesUK

Technical User
Sep 29, 2003
2
IT
Dear all,

How can I check to see if a directory has already been created on a drive. And if not then create it.

Thanks in advance

Darren
 
If Dir("Folder Path and name", vbDirectory) = "" Then MkDir ("Folder Path and name")

should do the trick for you

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Hi Darren
Try this, this uses a query to create the directory name and if it does not already exit , it creates it.
Function TRI()

Dim strOutDir As String 'location of output files
Dim dbs As Database, rstFolder As Recordset


DoCmd.SetWarnings False

DoCmd.OpenQuery "COB Date Required", acNormal, acEdit ‘this query produces name of the folder

Set dbs = CurrentDb
Set rstFolder = dbs.OpenRecordset("DATEREQ")
strFolder = rstFolder!COBDATE

strOutDir = "C:\jrnlstb\" & strFolder

If Dir(strOutDir, vbDirectory) = "" Then
FileSystem.MkDir strOutDir ‘ this bit makes the directory if it does not exist
End If

End Function

Regards Eddie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top