Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically creating a directory

Status
Not open for further replies.

nkdoshi

IS-IT--Management
Sep 12, 2000
7
US
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! [sig][/sig]
 
MkDir "C:\Bob"

thats how you do it in real vb anyway, vba should be the same. [sig][/sig]
 
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 [sig][/sig]
 
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
[sig][/sig]
 
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.
[sig][/sig]
 
Thanks so much! Installing SCRRUN.dll worked perfectly! [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top