Results 1 to 5 of 5
  1. #1
    thecsmith70 is offline Novice
    Windows 2K Access 2007
    Join Date
    Sep 2014
    Posts
    15

    Sample DB - Automating mapped drive

    Hello -

    This posting has two challenges:

    1st - I'm trying to automate mapped drive (address) in a field.

    Here's what I did: I created a form with the following fields: ID, FirstName, LastName, DOB and ChildsFile. The ChildFile is a address where the folder is located on the shared drive. In this case, it is on the S:\ChildsFile\*

    If you go to the form, you can enter the first and last name along with the DOB. You'll see the ChildFile's being autopopulated on the form.

    I just cant figure out how to save or append the autopopulated ChildFile info on the table (tbl_childsfile). The ChildFile field will end up just blank on the table.

    2nd - Using the above example, if you type in John, Doe, and 07012013 in the three fields, then the childsfile will be S:\ChildsFile\Doe_John_07012013. Is there a way to automate a new folder in a shared drive without having to manually create the new folder itself?

    I'm more interested in problem #1 above. Solving problem #2 would be a nice bonus (and less manual work for me).



    I've attached a 2007 file to help you see what I've started.

    Thanks.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Don't use drive letter pathing. Use UNC (Universal Naming Convention). The path would be like:

    \\servername\folderpath\filename

    Code to create a folder:

    strPath = "some UNC path you build in code"
    If Dir(strPath, vbDirectory) = "" Then MkDir strPath

    Be aware that the upper folders have to already exist otherwise must test for and create each level if not already existing.

    Also, permissions must allow for creating folders/files.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    NOTE using paths with drive lettters can cause problems. OTHER people may not have S mapped. Use UNC paths... \\server\folder1\folder2
    But if letters work for you , cool.

    vDir = [last] & " " & [first] & [InfoNum]
    Then You can create a folder name in code with : MakeDir vDir

    Code:
    Public Sub MakeDir(ByVal pvDir)
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(pvDir) Then fso.CreateFolder pvDir     'MkDir pvDir
    Set fso = Nothing
    End Sub

  4. #4
    thecsmith70 is offline Novice
    Windows 2K Access 2007
    Join Date
    Sep 2014
    Posts
    15
    Got it about UNC paths. Thanks for the info.

    I'm very new to this, so to code as you suggested, do I need to trigger an event (on enter) and use Code Builder?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Yes, this is VBA code. Possible events: AfterUpdate, Click
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 01-30-2014, 10:55 AM
  2. Replies: 3
    Last Post: 05-21-2013, 05:48 AM
  3. Link tables to server name, not mapped drive letter in Win 7
    By sleake in forum Import/Export Data
    Replies: 8
    Last Post: 11-16-2012, 10:48 AM
  4. Replies: 1
    Last Post: 04-16-2012, 08:34 AM
  5. Replies: 10
    Last Post: 03-04-2012, 12: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