473,385 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Mk Dir Command to create a folder with ID values from record and subfolders

I am trying to make a directory for my proposal database

I am trying to associate the code with a command buttom that opens a form to add a new record.

This is what I am trying to accomplish but since I am new at vba I need some help.

I would like when you add a new record to make a new folder with the mkdir command that includes the Proposal ID and Proposal Name.

This is the code I have so far.

If Len(Dir("z:HCHINC\PROPOSALS\Proposalprojects\TEST, ")) = 0 Then
MkDir "Z:HCHINC\PROPOSALS\Proposalprojects\TEST,"

I need to know how to make it have the Proposal ID and then the Proposal name instead of TEST? I also was wondering if someone can direct me in the right direction as to putting some stardard folders inside the directory folder like Drawings, Quotes, Correspondence etc.
Feb 6 '15 #1
4 1640
Rabbit
12,516 Expert Mod 8TB
Use the append operator (&) to append strings together. In this case, use it to append your proposal name to the string.
Expand|Select|Wrap|Line Numbers
  1. MkDir "Z:HCHINC\PROPOSALS\Proposalprojects\" & ProposalName
The standard folders can be created the same way you're creating the main folder.
Feb 6 '15 #2
jforbes
1,107 Expert 1GB
I use this to make sure a folder exists before dropping files into it. It will create the folder if need be and it's recursive so it will create the entire tree if necessary:
Expand|Select|Wrap|Line Numbers
  1. Function establishFolder(ByRef sPath As String) As Boolean
  2. On Error GoTo ErrorOut
  3.     Dim sParentFolder As String
  4.     establishFolder = False
  5.  
  6.     If Not folderExists(sPath) Then
  7.         sParentFolder = Left(sPath, InStrRev(Left(sPath, Len(sPath) - 1), "\") - 1)
  8.         If Not folderExists(sParentFolder) Then
  9.             If InStr(sParentFolder, "\") Then
  10.                 Call establishFolder(sParentFolder)
  11.             End If
  12.         End If
  13.         If folderExists(sParentFolder) Then
  14.             MkDir sPath
  15.             establishFolder = True
  16.         Else
  17.             establishFolder = False
  18.         End If
  19.     Else
  20.         establishFolder = True
  21.     End If
  22. ExitOut:
  23.     Exit Function
  24. ErrorOut:
  25.     MsgBox Err.Description
  26.     Resume ExitOut
  27. End Function
  28.  
  29. Function folderExists(strPath As String) As Boolean
  30.     On Error Resume Next
  31.     folderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
  32. End Function
  33.  
It can be used like this:
Expand|Select|Wrap|Line Numbers
  1.     If establishFolder("C:\bytes\temp\folder\" & sProposalName) Then
  2.         MsgBox "Folder Exits."
  3.     Else
  4.         MsgBox "Couldn't create the Folder."
  5.     End If
  6.  
Feb 6 '15 #3
I need it to create the proposal ID & Proposal name which are pulled from the field in the table? it doesn't seem to be working with the reply to the first answer.
Feb 6 '15 #4
Rabbit
12,516 Expert Mod 8TB
Please show us the code you tried and tell us how you called the code.
Feb 6 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tom Cusick | last post by:
We have a Job Shop database. When I get an order in I put all the line item information into the database. Some orders have multiple lines and most of the information is the same. (eg. Customer...
2
by: Cassandra | last post by:
My data entry form has thirty one fields. After I go to a new record and enter all the fields, how can I create another new record out of the same data? Sometimes when I am entering new records,...
6
by: Robert | last post by:
Hello, Accessors What I would like to do is create a multi-record table update. I have a table and a form for it. I want to modify it so that there is a new field (textbox) (not bound to a...
8
by: Ray | last post by:
I have a data input form and need to automatically duplicate the existing record as a new record by clicking a button. The main purpose to duplicate the record is that the new record is very...
0
by: Ed | last post by:
All of a sudden my previously working code started throwing this error. from the SqlDatasource. I am using C# and Asp.net 2.0. Getting the following error: You have specified that your delete...
7
by: FNA access | last post by:
I have a mainform that has a subform in the detail section and a subform in the footer section.(Both subforms are in datasheet view) When I click the navigation button to create a new record on the...
0
by: ryan | last post by:
I am new to vb.net programming and i am trying to figure out a programming issue. I have two forms. One is a list view that has a data bound grid. There are New and Edit buttons on the bottom. ...
1
by: dstorms | last post by:
Hi folks, I am trying to set up my database to create a new record in one table when a new record is created in another. Since it is a one-to-one realtionship it certainly would be easier to put...
2
by: Noorain | last post by:
sir how to create folder to use php script? i know how to file upload in folder to use php. but i can't how to create folder. i type name & its create my folder. Example: Type: test. my...
9
by: Becker | last post by:
I am trying to create a button to create a new record on the open form. Using the navigation buttons at the bottom I can go to a new record. For my users I would like to create a button, though. I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.