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
327 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 85

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 85
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

631 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