Len(Dir..... syntax

G

Guest

Hello again everyone,
I have this bit of code returns a zero value even if the directory does
exist. The msgbox Temp_Path shows the correct Path and folder name.

Can someone help me with the syntax on this?

Small piece of the code.

MsgBox "Step1"
Temp_Path = Path & "Teacher Reports"
MsgBox Temp_Path
If Len(Dir(Temp_Path)) = 0 Then
MsgBox "Teacher Reports Does not exist"
End if

Thank you very much for your assistance.
 
R

Ron Weiner

If Path & "Teacher Reports" is a directory change your code to:

If Len(Dir(Temp_Path, vbDirectory)) = 0 Then
 
G

Guest

Evidently my code is locking out the directory I am writing the file to.... I
close the form and goto windows explorer and try to delete the folder by code
just created, receive error message that says folder locked by another
program.

I placed this code at the end of my routine, but the folder is still locked.
Any other way to release the lock on the folder that is several levels deep
under the Path (returns path of current database) ?

ChDir Path
' also tried ChDir "C:"
 
R

Rob Oldfield

I've just tried it and your code (with Ron's tweak) doesn't cause the issue
you're describing. Is that all the code? I'd suspect that something else
that you're doing is locking the folder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top