Results 1 to 6 of 6
  1. #1
    maxbre is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    38

    Question vba code to create a dir

    hi all

    I need some hints in order to write some vba code I would like to attach to a button in a form

    the button should perform the following operation:
    create a directory which name is taken from a field of the same form and the new directory should be created in a specific given path (to be set)

    is that all possible?
    any help?



    thanks

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Ask Help about MKDIR.

  3. #3
    maxbre is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    38
    thanks for your reply
    Is there an alternative way to the brutality of my rough coding given below
    (I'm referring in particular to the error control )

    I've been trying with an if statement including "folderexists" but I was completely unsuccessful: any hint for this?

    tank you


    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >
    Private Sub creadir_Click()
    Dim FullPath As String
    FullPath = "c:\documents and settings\massimo\desktop\" & Me.lista_dir.Value & "\"
    On Error GoTo here
    MkDir FullPath
    Exit Sub
    here:
    MsgBox "dir already exists"
    End Sub

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Code:
    If Dir("ThisFile") <> vbNullString Then
       'Dir already exists.
    Else
       'Create the dir
    End If
    ...should do it here.

  5. #5
    maxbre is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    38
    with a slight variation your code worked fine

    If Dir("theDir", vbDirectory) <> vbNullString Then
    'Dir already exists.
    Else
    'Create the dir
    End If

    thanks

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Glad you got it working.

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

Similar Threads

  1. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  2. help me create relationship
    By Candy in forum Access
    Replies: 7
    Last Post: 05-29-2010, 07:43 PM
  3. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  4. Need to create a new db
    By ori in forum Access
    Replies: 5
    Last Post: 05-26-2009, 05:24 AM
  5. how to create a macro or code to...
    By Eaglezinha in forum Access
    Replies: 1
    Last Post: 10-20-2008, 04:01 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