Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
328 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 1000 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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