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
322 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

747 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

10 Experts available now in Live!

Get 1:1 Help Now