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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a New Directory / Folder using Access

Status
Not open for further replies.

Pampas58

Technical User
May 27, 2004
24
0
0
US
Greetings to all who chose to read this question:

I have a very simple application, it tracks the test reports for the engineering group. We create an E-File number, then we manually create a folder by that name and then we stuff the reports there manually.

Question; who can I have Access Create the folder from the newly created E-File Number I just generated?

Pardon my ignorance, but with your help I can cure it.

Pampas

Thanks for your help, the ignorace you jusst cured... is mine

Tempus Fugit, ergo carpe diem
 
File System Object is the key here...
U will need to add a Reference to the File System object in order to compile the VBA Code.

<code>

Dim fs As FileSystemObject 'declare file system object
Set fs = New FileSystemObject 'instantiate object
If Not fs.FolderExists("C:\Program Files\My Bike Log\BikeLogText") Then
fs.CreateFolder "C:\Program Files\My Bike Log\BikeLogText"
End If

</code>



Steve Medvid
IT Consultant & Web Master

Chester County, PA Residents
Please Show Your Support...
 
You can use the MkDir VBA statement:
Code:
Public Function MakeFolder(pstrFolder As String) As Boolean
   On Error GoTo MakeFolder_Error
    If Len(Dir(pstrFolder)) = 0 Then
        MkDir pstrFolder
        MakeFolder = True
    End If

   On Error GoTo 0
   Exit Function

MakeFolder_Error:
    Select Case Err.Number
        Case 75  'can't do it
        Case Else
            MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure MakeFolder of Module Utility Functions"
    End Select
End Function

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top