Folder making with vba

XXD

Registered User.
Local time
Today, 01:08
Joined
Mar 11, 2008
Messages
68
Hello everyone

I'm not very good at MS access so I am getting some trouble with a project I'm working on.
The thing I'm going to do is to make a database that can make folders where to be able to put new folders and also import files. All folders shall be editable and you may put new files(pictures, documents etc) and also delete old files.
You shall also be able to search for some specific file and from the database also open the file.
Everything shall be made through forms in the access database.

My question is very open and I'm receptionto all suggestions about how I may do this.

To make new folders I use mkDir("c:\newFolder") but what I want is to replace my text newFolder with the text I write in a textbox, in a form, in the database.

I would appreciate if the answers is explained in an easy way since I am a newbeginner.


Thank you so much for your time
 
I would think you could do something like

Code:
dim strFolder as string

strFolder = me.MyTextBoxName

mkDir("c:\" & strFolder)
 
Thank you so much. That solved the problem but you won't get rid of my questions this fast :).
I have a new problem, now I want the folders to be created in the same directory as the database.
 
I would put that in a public variable and call it.
 
haha, this is embarrasing.
Can you show me more specific how I can do that?
 
Put this in a stand alone code module:

Code:
Public Const STR_DB_DIR As String = "C:\LocalFiles"

And the code would then change to:

Code:
dim strFolder as string

strFolder = me.MyTextBoxName

mkDir(STR_DB_DIR & strFolder)

(This is actually consider a public constant and not a variable)
 
Thank you, it works.
But I may be back with new problems ;).
 
you could try this
"CurrentProject.Path"

This shows the path of the database so....

Code:
dim strFolder as string

strFolder = me.MyTextBoxName

mkDir(CurrentProject.Path & strFolder)
 
you could try this
"CurrentProject.Path"

This shows the path of the database so....

Code:
dim strFolder as string

strFolder = me.MyTextBoxName

mkDir(CurrentProject.Path & strFolder)

and I would go with this solution as it changes if it changes location whereas the other solution does not.
 
ok, very nice.
Thank you everyone.
 
and I would go with this solution as it changes if it changes location whereas the other solution does not.

I'd rather hard code the path, that way you have the option of putting them where ever you want. Frankly, if I'm creating files and folders that the end users will be poking around in via windows, I'd rather they be if different locations...

Edit: Let me change that to "I'd rather designate the path" at config time, whether it be a constant or variable or even a value stored in a table.
 
I'd rather hard code the path, that way you have the option of putting them where ever you want. Frankly, if I'm creating files and folders that the end users will be poking around in via windows, I'd rather they be if different locations...

But the OP said that they wanted the folders to be created in whatever folder the database was in and the CurrentProject.Path accomplishes that without coding changes necessary if you want to move the database.

Also, I would not "hard code" anything if possible. Things should be table/data driven so that you can make changes without coding changes. That is the philosophy of my current employers and that is a good one. Reusability is a key feature of good programming so that you don't need to go make programming changes for minor changes in function. You just change what you feed it and it then can still function without a programmer getting involved.
 
But the OP said that they wanted the folders to be created in whatever folder the database was in and the CurrentProject.Path accomplishes that without coding changes necessary if you want to move the database.

Also, I would not "hard code" anything if possible. Things should be table/data driven so that you can make changes without coding changes. That is the philosophy of my current employers and that is a good one. Reusability is a key feature of good programming so that you don't need to go make programming changes for minor changes in function. You just change what you feed it and it then can still function without a programmer getting involved.

Is it safe to assume you're really online and I'm not wasting my time relpying?

Edit: My bad, I see Bob has his green light disabled so I'm not sure when to reply to him or not...?
 
Last edited:
So after a 10 minute pause I guess Bob is offline...

Anyway XXD, I wouldn't put the data files in the same folder as the .mdb. Your end users could accidentaly delete it, etc. Just my opinion. Other than that Kenln's "CurrentProject.Path" is a neat trick to remember...
 
thanks again for everything.

I wonder how I can make a button that can attach files to the folder I just created?

I also want to know if I can make a search window that can search trough all the folders and the folders subfolders?
 
Last edited:
I'm going to bow out of this one and let Bob handle it since he's the senior forum member and an MVP ;)
 
If he don't respond soon I'll take another peek - :)
 
This may take more time than I will have today. I may answer an occasional question if it doesn't take more than a few seconds, but I have to get a couple of things done before I leave for the MVP Summit and so Ken - feel free to take a stab at it if you feel so inclined.
 

Users who are viewing this thread

Back
Top Bottom