directory folder creator

brsawvel

Registered User.
Local time
Today, 15:36
Joined
Sep 19, 2007
Messages
256
hello,

Is there a code that, when a textbox is filled with data, a folder can be automatically generated in a predesignated directory?
 
Thanks Mr. B....

Looking at the code for making a directory, what if I want the folder to be named after the value in fldA?

Code:
MkDir "c:\fldrA\[B][COLOR=darkorange]****fldA.Value****[/COLOR][/B]"

Also, do you recommend adding the following code to avoid errors?

Code:
If Len(Dir("c:\fldrA\[COLOR=darkorange][B]****fldA.Value****[/B][/COLOR]", vbDirectory)) = 0 Then
    MkDir "c:\fldrA\[COLOR=darkorange][B]****fldA.Value****[/B][/COLOR]"
End If

Finally, is it ok to place this code in the OnChange portion of FldA? I don't want to rely on the user to click a save button. Else I'll need to create a warning text box that says the record won't be saved unless the person clicks the save button.
 
Sorry for taking so long to get back to you, but I could not get logged on to this site today.

You will need to use the MkDir for each level at which you need to make a new directory.

You can use the code anywhere that will work for you, but if this field is the one that will need to cause the folder(s) to be created, then I would consider using the "After Update" event of the control and not the "On Change" event becase the "On Change" event will first everytime the user makes any change to the value in the field, but the "After Update" event will only fire one time when the user has completed entry and moves off of the control.
 
Thank you for the info...One last question, though? How do I write the code so that the folder name is the same as the value of fldA?
 
If you want to create the name that is being held in field A then the code should be something like:
If Len(Dir("c:\" & me.fldA, vbDirectory)) = 0 Then
MkDir ("C:\" & Me.fldA)
End If
 

Users who are viewing this thread

Back
Top Bottom