Results 1 to 8 of 8
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    Referencing a local drive for all users

    I have an app that would display images stored in a shared server. I noticed that when navigating from record to record, it takes a while to display the images. In addition, when the user goes offline, the photos would not be available. Therefore, I would like to create a procedure that would allow the user to download all the photos from the network to their local device before going offline. I suspect that I can use FileCopy method to do the job. Question is, how do I reference a local folder like My Pictures/Folder1 without having the user's name in the path. When I go to My Pictures folder and copy the path, I get \\server\user\username\My Documents\My Pictures, which means, that path would only apply to a specific user. How do I reference the exact same local location for everyone?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can create a folder if it doesn't exist and put the files there

    c:\app\pictures\

    Filesystemobject commands make it very easy to validate path names/create/remove etc.

  3. #3
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    I have thought of that, creating a folder in the c: drive, but I just don't think that's a good way to organize photos in one's device. I think there's a relative path I can reference for everyone, I just haven't found what that is yet.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can capture the 'current user' of the database

    http://www.techonthenet.com/access/f...urrentuser.php

    You can try environ("username") to capture the current user of the machine

    https://social.msdn.microsoft.com/Fo...orum=accessdev

    and build the path from there.

  5. #5
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Great suggestion. environ("username") did the trick, at least on me. Hopefully it works for others. Thanks. Now I just need to be able to launch the Windows Photo Viewer, then I'm set. It's currently a challenge as it does not have a .exe file.

  6. #6
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    Quote Originally Posted by LonghronJ View Post
    Great suggestion. environ("username") did the trick, at least on me. Hopefully it works for others. Thanks. Now I just need to be able to launch the Windows Photo Viewer, then I'm set. It's currently a challenge as it does not have a .exe file.
    I tend to create a folder "SomeAppName" in vba.environ("temp") and use that for storage as you've outlined. It's reliable and users almost always have access rights to read and write temp folders.



    Jeff

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Just in case anyone else stumbles on this thread, I think the value you were looking for is C:\Users\%USERNAME%\rest of path here. %USERNAME% is often used in batch or command files. I know a person who always used the Environ variable but had to change all his databases - something changed in the company servers, but I don't recall what. Nothing wrong with the method if it works. There is also a way to get the user's network login id and look that up in a user table for any user data. You would find the code for that posted in this forum and many other places by searching for apiGetUserName.

  8. #8
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    Quote Originally Posted by Micron View Post
    Just in case anyone else stumbles on this thread, I think the value you were looking for is C:\Users\%USERNAME%\rest of path here. %USERNAME% is often used in batch or command files. I know a person who always used the Environ variable but had to change all his databases - something changed in the company servers, but I don't recall what. Nothing wrong with the method if it works. There is also a way to get the user's network login id and look that up in a user table for any user data. You would find the code for that posted in this forum and many other places by searching for apiGetUserName.
    If taking this approach then you will want to use vba.userprofile("userprofile") type variables set by windows. See https://technet.microsoft.com/en-us/...(v=WS.10).aspx for other environment variables managed by windows itself.

    Jeff

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

Similar Threads

  1. Max users on a network drive
    By data808 in forum Access
    Replies: 2
    Last Post: 10-23-2014, 02:12 AM
  2. saving data from Attachment field to local drive
    By saleemsadique in forum Access
    Replies: 5
    Last Post: 01-21-2014, 06:52 PM
  3. shared DB on local drive
    By mike02 in forum Access
    Replies: 1
    Last Post: 05-20-2013, 01:54 PM
  4. Replies: 2
    Last Post: 03-01-2012, 04:14 AM
  5. Multi Users on shared drive
    By wallen in forum Access
    Replies: 0
    Last Post: 08-25-2008, 08:57 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