Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    create a new directory and then delete the original one

    Hi All



    i have this code that creates the required folder structure when a form is opened

    If Len(Dir(DLookup("FilePath", "Settings", "ID = 1") & "\Assets" & "\" & Me.Type & "\" & Me.AssetName, vbDirectory)) = 0 Then
    MkDir (DLookup("FilePath", "Settings", "ID = 1")) & "\Assets" & "\" & Me.Type & "\" & Me.AssetName
    End If


    this works great, but what i really need to do now is this

    if the asset name "me.AssetName" changes i would like a new folder created "This i can do with the above code" and the original folder name deleted. "this i can't get my head around"

    so for example

    i create a new asset called Server 1
    a new folder is automatically created on the network called "server 1"

    if this server is renamed to server 2
    create a new folder called "server 2 " then delete the original folder called "server 1"

    any help would be great.

    Many Thanks

    Steve

  2. #2
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    You can try something like this:

    On the AfterUpdate event of the AssetName field, search for the Directory using Me.AssetName.OldValue (this would be "Server 1").
    Then use RmDir to remove that directory
    Then use MkDir to create the new directory.

    Beware though, RmDir will cause an error if the directory contains any files. If you want to delete the files then you can include these steps somewhere
    ChDir to old directory
    Kill("*.*")

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi thebigthing313

    brill many thanks for the help

    thats great

    Steve

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

Similar Threads

  1. Replies: 12
    Last Post: 10-27-2012, 05:44 AM
  2. Replies: 6
    Last Post: 10-26-2012, 12:53 PM
  3. Replies: 5
    Last Post: 05-02-2012, 07:56 AM
  4. Replies: 6
    Last Post: 06-15-2011, 04:38 PM
  5. Back to original form
    By hawzmolly in forum Forms
    Replies: 4
    Last Post: 09-26-2010, 07:36 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