Trap Error (1 Viewer)

*Pete*

Registered User.
Local time
Today, 20:31
Joined
Jul 17, 2006
Messages
40
Hi, I have a button that creates a folder, but if the folder already exists it comes up with a Run Time Error 75. I have the following code to try to stop this but it does not seem to work. Does anyone have any sugestions on how i can fix this.

Code:
If DataErr = 75 Then
MsgBox " Already Exists", vbCritical + vbOKOnly, "Error"
Else
strDirectoryPath1 = DLookup("Centre_DataLocation", "T_CentreDetails") & "\Files\ & [MainFolder]
MkDir (strDirectoryPath1)
End If

Pete
 

Banana

split with a cherry atop.
Local time
Today, 12:31
Joined
Sep 1, 2005
Messages
6,318
Should "DataErr" be just "Err" or maye "Err.Number"?
 

ghudson

Registered User.
Local time
Today, 15:31
Joined
Jun 8, 2002
Messages
6,194
That is not how you should test if a directory already exist.

Code:
If Dir("C:\temp\", vbDirectory) = "" Then
     MsgBox "Directory does not exist"
Else
     MsgBox "Directory does exist"
End If
 

Users who are viewing this thread

Top Bottom