Avatar of SteveL13
SteveL13
Flag for United States of America asked on

Create folder with command button

I want to use a command button on a form to create a specific folder on the user's computer.  The folder when created has to look like this:

C:\[ParticipantID] - [Participant Name]


The Participant ID and Participant Name come from two fields on the form named txtParticipantID and txtParticipantName.


If the folder does not exist, create it.  If it does already exist, open it.

Microsoft Access

Avatar of undefined
Last Comment
SteveL13

8/22/2022 - Mon
Ryan Chong

try such as:

Dim yourPath As String

yourPath = "C:\" & txtParticipantID.Value & " - " & txtParticipantName.Value

If Len(Dir(yourPath, vbDirectory)) = 0 Then
   MkDir yourPath
End If

Open in new window


SteveL13

ASKER
I forgot to mention that I want the created folder to look like:

C:\Participant Documents\[ParticipantID] - [Participant Name]

In other words, create the Participant Documents folder, which will contain all of the participants documents, if it isn't already there and then the subfolder with the Participant Documents


ASKER CERTIFIED SOLUTION
Ryan Chong

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SteveL13

ASKER
Perfect.  Now how do I open the folder once it's been created?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SteveL13

ASKER
(If I come back to the participants record on the form that is)
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SteveL13

ASKER
Thank you!