Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Images in Access 2007

Posted on 2016-09-13
Medium Priority
Last Modified: 2016-09-14
I have stored several images in a table. I then want to print one of more of these on a report. The report has a record source and and one of the fields called HGS_code in the record source determines which image i need to print. So i want to use the HGS_code to lookup a table called Pictograms with the pictures in there. Once the correct HGS_code is found, move the picture associated with the HGS_code to a field on the form to be printed.
Question by:Tony Crisafi
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
  • 4
  • 4
LVL 19

Expert Comment

by:John Tsioumpris
ID: 41795554
If you have stored your images as BLOBs then you use:
ImageControl.PictureData = rs.Fields("ImageData")

Open in new window

If you use Path of the Image then you use:
ImageControl.Picture= rs.Fields("ImagePath")

Open in new window

If you want to dynamically add pictures then you need some work ...like opening the report in design mode.adding the controls according to the number of images,close it and reopen it.

Author Comment

by:Tony Crisafi
ID: 41795557
Sorry John, i dont know what blobs are. I opened the .jpg image in IE and copied and pasted it into a form that was bound to the ole object field in a table.

Now i am trying to do a lookup on that table to get the image and display it in a report.

The object type that i have put on the report is an unbound object frame. Is that correct?



Author Comment

by:Tony Crisafi
ID: 41795586
This is the code i have so far.

 Dim rs_PI As Recordset
    Set rs_PI = CurrentDb.OpenRecordset("Pictograms", dbOpenDynaset)

    rs_PI.FindFirst "[GHS_Code] =  '" & GHS_Code_1 & "'"
'       rs_PI.FindFirst "[GHS_Code] = 'GHS01'"
    If rs_PI.NoMatch Then
        MsgBox "No record found."
        Exit Sub
        OLE_GHS_Pict1.PictureData = rs_PI("GHS_Pict")
    End If

But it come up with a run time error. Bit map you specified is not a device independent bitmap.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Assisted Solution

by:John Tsioumpris
John Tsioumpris earned 1500 total points
ID: 41795603
This is an ugly situation and the workaround is not straightforward...
Essential you can't copy/paste from the clipboard because in the OLE object field you get "Picture" instead of Long Binary data....UNLESS you use a Bound Object Frame
I am attaching a simple example....the key is to have an Image control and load the picture into this.
Then you copy the PictureData from the ImageControl to a recordset field and then you can use it on your report....
This sample is in Access 2013 but hopefully it will work...

Author Comment

by:Tony Crisafi
ID: 41795621
I'm using Access 2007. I cant see any images in the report?
LVL 19

Expert Comment

by:John Tsioumpris
ID: 41795725
It seems that Access 2007 lacks some rendering capabilities.....
I have code that works even on Access 2003 but needs cleanup....

EDIT...it seems that on the report i have a "Report_Current" event that causes crashing....please remove it and check again....
If it fails i will try to clean the code
LVL 19

Accepted Solution

John Tsioumpris earned 1500 total points
ID: 41795800
I have a sample for Access 2003 so it should work fine with 2007..
IMPORTANT Your source Images should be .BMP
Essentially as i mentioned before you should have an Image Control which you should use a temporary storage to get the correct binary file format in order to store it effectively as Long Binary File.
Later on you retrieve it and you use it via the PictureData property.
LVL 40

Expert Comment

ID: 41796292
Look at my article Images on continuous forms
In report you can use same technique

Author Comment

by:Tony Crisafi
ID: 41797374
Hi John,

after looking at your code closely and following it through. i understand what you have done and created binaries of my images that store OK.

But its annoying that i need to put the image into a form and then blog insert it into a table field bound to the form. The go back and edit the form to change the image and blob insert the image to the table field bound to the form again etc for each image.

Is there a way around this of how can i create a device independent bitmap to put in the table?


Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

636 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