×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Dynamically creating a directory

Dynamically creating a directory

Dynamically creating a directory

(OP)
How do I Code VB in Access 97 to create a directory on the C: drive based on the input of a user?

For example, If User Bob inputs his name in a given form as "Bob" and then clicks the "CREATE" button, how do I get the "CREATE" button to make "C:\Bob"?

Any help would be appreciated!

RE: Dynamically creating a directory

MkDir "C:\Bob"

thats how you do it in real vb anyway, vba should be the same.

RE: Dynamically creating a directory

(OP)
Thanks for your help!  The problem is that MkDir only creates a directory that you hardcode in.  It will not create a directory from a user input.

The other problem is that I have used the following code to make the directory I want, but it only works on Win 98 NOT Win NT.  I am using Access 97 and have administrator rights to the machine.

Dim fs, f, f1, fc, S, secfolder
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder("C:\asqhold")
    Set fc = f.SubFolders
    fc.Add [Form_Personal Data]!Name

I always get the error "Active X can't create object."  Is there another way complete this action?  Or does anyone know why this doesn't work on NT??

Thanks!
NkDoshi

RE: Dynamically creating a directory

I created a project in vb with a form with one text box and one command button. I put this in the command buttons click event.

Private Sub Command1_Click()
    MkDir Text1.Text
End Sub

I tested it by typing in "C:\test1" in the text box and the directory was created when i clicked the button. Will this not work in Access?

Also, that error means the 'Scripting' object that provides the filesystemobject you are trying to use is not registered on the NT machine.
let me know what exactly is not working about calling MkDir with a variable for a parameter and i will try to help you with it.

Ruairi

RE: Dynamically creating a directory

NkDoshi,
    Ok, i knew that thing about the filesystem object not working on NT reminded me of something, i just had to do some digging. Do a find on the machine the filesystemobject code works on for the file SCRRUN.DLL. This is the dll for the Microsoft Scripting Runtime Library it comes with VB6 and office 2K but obviously you already have it on that computer so find it and copy it to and register it on the NT machine (and any other computer you may distribute this to), that should make that code work.

RE: Dynamically creating a directory

(OP)
Thanks so much!  Installing SCRRUN.dll worked perfectly!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close