Results 1 to 9 of 9
  1. #1
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376

    How do I grab the Path for the database then use that for the path to where files are located?

    Hello all,

    I am trying to create a database that uses image files and the path to the image file is stored in a field of a table. My issue is is that I keep the file on a flash drive and when I work on this at home, the drive has 1 location ie. H: and when I work on it at work it will have another location E: so all of the paths are incorrect. Is there a way to find out the location of where the database was loaded from then use that as the starting location for the image files.

    Example Work: Work Laptop Database is Located on Flash Drive and has location of E:\ Login\Pictures\Image1.jpg
    Example Home: Home Laptop Database is Located on Flash Drive and has location of H:\ Login\Pictures\Image1.jpg



    Is there a way I can grab the location of the database starting point then just append that with the Image file name?

    That way, no matter what the drive letter is it would always find the image file.

    Does that make sense?


    Thanks

    Dave

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    CurrentProject.Path gets the path of your database so you need: CurrentProject.Path & "\Pictures"
    Last edited by isladogs; 10-12-2020 at 12:52 PM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    Awesome, Thanks Colin, I knew there had to be a way to do it.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You're very welcome.
    BTW I left off a trailing backslash by mistake - now added to previous reply
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    Colin,
    How do I now get then name of the file from that and place it in the image path?

    Thanks
    Dave

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    you have the path as a variable?

    strPath = CurrentProject.Path & "\Pictures" & someFileNameHere and that gives you

    H:\ Login\Pictures\Image1.jpg ?

    Then maybe
    Code:
    strPath = Mid(strPath,InstrRev(strPath,"\")+1)
    Interesting - forum strips backslash from within quotes if code tags are not used.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    That was my problem earlier. I didn't use code tags and the forum software removed the final backslash in my answer
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Ahh, I thought you meant you just forgot to type it in. I've experienced other weird effects in forums, the octothorpe being one of them.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I originally assumed that as well so added it later and completely forgot to recheck it until your post!
    Currently on my phone. Will try to fix later.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 2
    Last Post: 08-22-2018, 12:15 PM
  2. Replies: 5
    Last Post: 10-28-2014, 01:51 AM
  3. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  4. Replies: 3
    Last Post: 11-24-2012, 08:56 AM
  5. relink to relative path TXT data files
    By tobynegus in forum Programming
    Replies: 0
    Last Post: 08-19-2008, 10:10 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