Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access 2007 - Image Path

    I'm using Access 2007, and my end goal is to be able to display an image for each record.

    After looking at the various options, I chose to have the image in a separate folder on my PC, and in the primary record, have the image path. Then, in the form or report, I have an image frame, and the control source is the image path.

    Well and good. Except I realize the inherent maintenance issue, if I change the location of the folder, and the entire path is in the ImagePath field.

    So, I created an EnvironmentVariables table, and one row is the location of the image folder. My thought was that way I could change it in one place. My ImagePath column would be changed to ImageName. I was hoping I could somehow concatenate the two, to put in the ControlSource. But I haven't been able to figure out a way to do that, because they are in two different tables, and there is no relationship between them, so I can't have the form or report based on them both (or at least I haven't found a way).

    For the report, I created a workaround, where I created a query that included as a column in the query the concatenation of the two, and then I was able to use that column as the ControlSource on the report. But I use the form to actually update the primary table, so I don't think I can do that, which leaves me with no image on the form.

    My next thought was to have a column in the primary table for the Image Path, and somehow default it to whatever is in the Environment Variables.ImageFolder column. But I can't figure out how to do that either.

    Thoughts?
    Last edited by lliefveld; 2013-01-11 at 15:16. Reason: typo

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,535
    Thanks
    0
    Thanked 23 Times in 23 Posts
    Have you still got this problem, if so, would you post a zipped compacted copy of your database with any sensitive data removed.

  4. #3
    Lounger
    Join Date
    Dec 2009
    Location
    Findlay, Ohio
    Posts
    33
    Thanks
    4
    Thanked 3 Times in 3 Posts
    I do (kinda) the same. I just store the pic name (i.e. fred.jpg) in the database and append the path for what I to want to display the image in the form by using
    Private Sub Form_Current()
    EquipPath = getdir()
    If Me.Equip_Pic_Location <> "" Then
    Me![pic1].Picture = EquipPath & Me.Equip_Pic_Location
    Else
    Me![pic1].Picture = ""
    End If
    end sub
    For the report I used control source =getdir() & [Equip_Pic_Location]

  5. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,535
    Thanks
    0
    Thanked 23 Times in 23 Posts
    That will work. Why didn't you put the path and filename as one field in the table? You could then use a bound image control (Control Source is used for this in Access 2007) on the form and report to display the image.

  6. #5
    Lounger
    Join Date
    Dec 2009
    Location
    Findlay, Ohio
    Posts
    33
    Thanks
    4
    Thanked 3 Times in 3 Posts
    I was concerned that the end user who I wrote it for would put in it a directory name of his choosing (not the one I developed it in) so I grab the current directory I'm running in. This way who cares where he put the code and pictures. The getdir does a simple grab of current directory. I probably could have grabbed a variable also but did it this way.
    Function getdir()
    Dim curdir As String
    curdir = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
    getdir = curdir
    End Function

  7. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,535
    Thanks
    0
    Thanked 23 Times in 23 Posts
    What happens if he chooses to put them in another folder to the current directory? They should be told where to put them and that's that, just by 2 bobs worth.

  8. #7
    Lounger
    Join Date
    Dec 2009
    Location
    Findlay, Ohio
    Posts
    33
    Thanks
    4
    Thanked 3 Times in 3 Posts
    I decided against that approach. I told them everything has to be in the same directory, name it whatever you want.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •