Results 1 to 4 of 4
  1. #1
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92

    Question re: path I should use when listing file names in a table

    I need to attach an image file to each record in a table, because I want them to show up in one of my reports. Instead of actually attaching the image, I am creating a ShortText field where I will put the path to the file (which lives on my hard drive). This way the size of my database won't get too big once I have thousands of images attached.

    I will be using this database on two different computers, and depending on which computer, the path where the images will be stored will be slightly different.



    The two paths will be:

    Desktop computer -- C:\Users\Matt\OneDrive\Documents\Images
    Laptop computer -- C:\Users\MattC\OneDrive\Documents\Images

    (The database itself will live in "\OneDrive\Documents")

    I have tried using "\Images\imagefile.png" in the field of my table, but the image doesn't show up on my report. So, what I'm wondering is, how can I list the path so that the images can live inside a folder WITHOUT listing the entire path in my table field? Is that even possible?

    BTW, I'm using Access 2016.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    You can get the path to the database location with

    CurrentProject.Path

    and just store the path from there. Concatenate them for the full path.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Thanks very much for this! I'm still pretty new to Access, so it took me a bit to figure out what exactly I needed to do, but finally got it.

    For anyone else reading this who needs to know how to do it, here's what I did:

    I went to my report, and went into Design View.

    I clicked on the Image box that I had created for where I want my image to appear, then bought up the properties sheet.
    I hit the "..." on the line for Control Source, and inside the expression builder, I replaced Image (the field where my path & file name is stored) with CurrentProject.Path & "\Images\" & Image

    In the Image field of my table, instead of listing any path at all, all I listed was the file name itself (with extension).

    Thanks again, pbaldy!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 09-22-2014, 03:36 PM
  2. Replies: 7
    Last Post: 08-20-2014, 03:00 AM
  3. Replies: 2
    Last Post: 11-06-2013, 10:43 AM
  4. Replies: 10
    Last Post: 03-04-2012, 12:17 AM
  5. Importing file names into a table?
    By davetheant in forum Forms
    Replies: 6
    Last Post: 06-10-2011, 10:37 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