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
323 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:jrsitman
  • 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:jrsitman
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:jrsitman
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:jrsitman
ID: 37809175
Thanks for the help.  It's working
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now