Solved

How do you add an image to a report that is different for every report in Access 2007

Posted on 2012-04-02
7
326 Views
Last Modified: 2012-04-05
We have a database that has all of our animlas up for adoption.  In one of the forms there is an picture of the animal.  I'm creating a new report that needs to have all the specific animal information on it.  Below is the code that puts the picture on the form.  I didn't write it and I need help figuring out how/what I do on the report to get the picture inserted per animal.

SoftSlipPicPathFile is the field in the table that contains the picture


Private Sub cmdImgAnimal_Click()
Dim strFilter As String, strDefaultPath As String
Dim varFileName As Variant

On Error Resume Next

strFilter = ""
strFilter = adhAddFilterItem(strFilter, "Images (*.jpg)", "*.jpg")
strFilter = adhAddFilterItem(strFilter, "Images (*.bmp)", "*.bmp")
strFilter = adhAddFilterItem(strFilter, "Images (*.gif)", "*.gif")
strFilter = adhAddFilterItem(strFilter, "Images (*.png)", "*.png")

strDefaultPath = GetImagePicturePath_Generic("SoftSlips")
If strDefaultPath = "" Then strDefaultPath = CurrentProject.Path

Select Case Me.lblNoImgAvail.Visible

    Case True
        ' Display Open File dialog using
        ' adhCommonFileOpenSave from basFileOpen.
        varFileName = adhCommonFileOpenSave( _
            OpenFile:=True, _
            Filter:=strFilter, _
            flags:=cdlOFNHideReadOnly + cdlOFNNoChangeDir + cdlOFNExplorer, _
            InitDir:=strDefaultPath, _
            DialogTitle:="Locate Image file")
       
        If IsNull(varFileName) = False Then
            ' User selected a file.
            varFileName = adhTrimNull(varFileName)
            Me.SoftSlipPicPathFile.Value = varFileName
            Call FillInTheAnimalImage("SoftSlips", False)
        End If
       
       
    Case False
        If vbYes = MsgBox("Do you want to delete the image?", _
            vbQuestion + vbYesNo + vbDefaultButton2, "Delete the Image?") Then
            Me.SoftSlipPicPathFile.Value = Null
            Call FillInTheAnimalImage("SoftSlips", True)
        Else
            ' Display Open File dialog using
            ' adhCommonFileOpenSave from basFileOpen.
            varFileName = adhCommonFileOpenSave( _
                OpenFile:=True, _
                Filter:=strFilter, _
                flags:=cdlOFNHideReadOnly + cdlOFNNoChangeDir, _
                InitDir:=strDefaultPath, _
                DialogTitle:="Locate Image file")
           
            If IsNull(varFileName) = False Then
                ' User selected a file.
                varFileName = adhTrimNull(varFileName)
                Me.SoftSlipPicPathFile.Value = varFileName
                Call FillInTheAnimalImage("SoftSlips", False)
            End If
        End If
       
End Select
0
Comment
Question by:J.R. Sitman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 37796151
Is SoftSlipPicPathFile the PATH to the image, or does that field contain the image itself? Sounds like it's the path, but check that to be sure.

If it's the path, then you can add an Image control to your Report and use that section's Format or Print event to set the value of the Image Control's .Picture property:

Me.YourImageControl.Picture = Me!SoftSlipPicPathFile

Note that SoftSlipPicPathFile will need to be on the report itself (it can be in a hidden textbox) in order for this to work.
0
 

Author Comment

by:J.R. Sitman
ID: 37796260
The image is assigned manually to each animal. It is stored in a folder on the server and assigned using the code I posted.  When you click the "assign image" it takes you directly to the folder.  I'm not sure how it knows where the folder is because in the code I don't see the folder name anywhere.
0
 
LVL 84
ID: 37796427
You wrote this:

SoftSlipPicPathFile is the field in the table that contains the picture

What value does "SoftSlipPicPathFile" contain in the table? Is it a standard file path, like C:\My Documents\My Folder\someimage.gif, or is it something else?

The code you supplied doesn't really save the values for you - it just calls other functions, like "FillInTheAnimalImage", which seem to do the heavy lifting for the process.
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:J.R. Sitman
ID: 37796612
attached is the path
softslippicpath.png
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37796701
<How do you add an image to a report that is different for every report in Access 2007>
Do you mean" "...different for every "Animal"...?

Here is the very basic, simply system I use...
(it may need to be tweaked for 64 bit windows though...)
Access-BasicLinkOpenFileDialogBo.mdb
0
 

Author Closing Comment

by:J.R. Sitman
ID: 37809175
Thanks for the help.  It's working
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question