Results 1 to 7 of 7
  1. #1
    rmb89 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2019
    Posts
    3

    Make Folder button Error with name folder based off of a field in form

    Hey everyone, I am new to Access and I have managed to somehow get all of my buttons to work except one, my button that makes folders. I can get it to make folder where I want it, but I can not get it to name the folder based off of a certain field on my form. I also need it to copy a folder template each time it goes to make a new folder, but was trying to get this part to work first. Any advice would be great. I feel like I am missing something very simple in the code and I have searched for a few days and watched multiple videos with no success.



    here is the code I am currently using:
    Code:
    Private Sub Command452_Click()
    Const FOLDER_EXISTS = 75 Dim strFolderPath As String strFolderPath = "C:\Access Pipeline\Projects" On Error Resume Next MkDir "C:\Access Pipeline\Projects" Err.Clear MkDir "C:\Access Pipeline\Projects\" & "Project_Name" Err.Clear MkDir strFolderPath Select Case Err.Number Case 0 ' no error Case FOLDER_EXISTS ' folder exists so open it Application.FollowHyperlink strFolder Case Else ' unknown error so inform user MsgBox Err.Description, vbExclamation, "Error" End Select End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If you mean this line:

    MkDir "C:\Access Pipeline\Projects" & "Project_Name"

    you don't want quotes around the value. More like:

    MkDir "C:\Access Pipeline\Projects" & Me.Project_Name

    presuming Project_Name is the name of the textbox with the value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rmb89 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2019
    Posts
    3
    When I did that it said, "Path not found."

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I somehow deleted the backslash. Try

    MkDir "C:\Access Pipeline\Projects" & Me.Project_Name
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Okay, I didn't delete it, the forum software keeps dropping it. Make sure you add one after Projects.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    rmb89 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2019
    Posts
    3
    Thank you so much! That did it!!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Create Folder based on field names
    By dinsey90 in forum Access
    Replies: 12
    Last Post: 10-04-2017, 03:38 PM
  2. Replies: 10
    Last Post: 09-09-2015, 03:25 AM
  3. Browse and Open Folder Based on Matching Form Field
    By Tomfernandez1 in forum Access
    Replies: 11
    Last Post: 02-26-2013, 01:04 PM
  4. Replies: 4
    Last Post: 09-18-2012, 11:30 PM
  5. open folder/Make new folder(example)-VBA Code
    By Madmax in forum Code Repository
    Replies: 3
    Last Post: 03-13-2012, 09:17 AM

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