• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Create a sub folder from Access 2003

I have a MS Access 2003 membership database (operating system is Windows XP).  

In a form I want to be able to create a command button which sets up a sub folder in a specific drive to store documents related to that person.  

The file path for where the sub folder is to be created is: C:\ My Documents\CDG\Members Files\

The naming protocol for the subfolder would be [First Name]-[Last Name]-[ID] i.e. Dave-Smith-123

The end result in this example would therefore be a folder file path of : C:\ My Documents\CDG\Members Files\ Dave-Smith-123

If the subfolder already exists then I need a message box to come up and say Sub Folder Already Exists & doesnt try & create a new one.

Can anyone help?
0
correlate
Asked:
correlate
  • 2
1 Solution
 
rockiroadsCommented:
ok, try this

dim sRoot as string
dim sFolder as string

sRoot = "C:\ My Documents\CDG\Members Files\"
sFolder = Me.First_Name & "-" & Me.Last_Name & "-" & Me.ID

if dir$(sRoot & sFolder, vbdirectory) <> "" then
    msgbox "Already exists"
else
    mkdir sRoot & sFolder
end if
0
 
rockiroadsCommented:
explanation

sFolder is just built up using string concatenation

dir$(..., vbDirectory) returns empty string if it doesnt exist so we check to see if it is not, then display message otherwise we create the directory using mkdir
0
 
correlateAuthor Commented:
Works a treat -thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now