Results 1 to 4 of 4
  1. #1
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80

    open folder/Make new folder(example)-VBA Code

    Okay I have been working on this for two weeks and even though it cheats I finally got this to work and wanted to post it should anyone ever want to use it.




    Code:
    Private Sub Command152_Click()
    Dim LFolderpath As String
    Dim LResponse As String
    On Error GoTo NFolder
    LFolderpath = CurrentProject.Path & "\digitalfiles\" & [Last Name] & "_" & [First Name] & "_" & [ID]
    If Len(Dir("LFolderpath", vbDirectory)) = 0 Then
    Application.FollowHyperlink LFolderpath
    End If
    Exit Sub
    NFolder:
    LResponse = MsgBox("Folder doesnt exist for " & [Last Name] & ", " & [First Name] & ".  Would you like to create a new folder?", vbYesNo)
    If LResponse = "6" Then
    MkDir LFolderpath
    Application.FollowHyperlink LFolderpath
    Else
    MsgBox ("No folder created and no folder exists")
    End If
    End Sub

  2. #2
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80
    Coulple of notes
    Line 5 notes--it takes the path where your database is searches for the digitalfiles folder and either opens or creates the folder inside the digitalfiles folder. Side note, you must have the digitalfiles folder created or change the information on line 5. Also, you must use your fields on line 5.
    This thing cheats because it kept getting stuck on line 7 with an error if the folder did exist. So I used the on error button to go to the next if statement. It shouldnt ever error for anything else but it does work this way so far that I have found.

    I dont want credit btw, Most of the folks here at the forums taught me almost every part of that code at some point or another.

    MadMax

  3. #3
    morchidi is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    1
    I've got this code from the forum today and I want to apply to this program and the facility if possible Thanks
    MORCHIDI

  4. #4
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80
    did you have a question then?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Browse and Open Folder Based on Matching Form Field
    By Tomfernandez1 in forum Access
    Replies: 11
    Last Post: 02-26-2013, 01:04 PM
  2. Browse For Folder Example
    By pkstormy in forum Code Repository
    Replies: 6
    Last Post: 01-08-2012, 04:13 PM
  3. Button to Open a Specific Folder
    By dnelms in forum Programming
    Replies: 1
    Last Post: 04-08-2011, 10:05 AM
  4. Enter a folder name and open that folder
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 09-05-2010, 04:39 PM
  5. Make directory or folder
    By thart21 in forum Programming
    Replies: 1
    Last Post: 04-07-2010, 05:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums