View Full Version : Checking for Directory


harrisw
07-25-2002, 01:15 AM
have the code below checking if a directory exists:

JobRef = Left(Form_frmViewJob.txtJobReference, 8) & " - " & Right(Form_frmViewJob.txtJobReference, 6)

Me.dlgViewJobFolder.InitDir = "w:\dosapps\delta5\private\b2bdbase\borisdata\" & JobRef

If Dir(Me.dlgViewJobFolder.InitDir) = "" Then
MsgBox ("Directory not exist " & Me.dlgViewJobFolder.InitDir)
GoTo exit_sub
End If

Me.dlgViewJobFolder.showopen

For some reason it always drops into the "directory not exist message" even if the directory does exist.

Please help.

ghudson
07-25-2002, 05:58 AM
You are missing the vbDirectory option. Chech the help file for more options with the Dir function.

I am using Access 97 so I am not sure what your ".IntDir" is.

If Dir(Me.dlgViewJobFolder.InitDir, vbDirectory) = "" Then

To test your return, I suggest that you call the "Me.dlgViewJobFolder.InitDir" in a message box like
MsgBox Me.dlgViewJobFolder.InitDir

HTH

harrisw
07-25-2002, 06:30 AM
Great, works fine with the vbdirectory bit in