Solved

Images in Access 2007

Posted on 2016-09-13
9
41 Views
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.
0
Comment
Question by:Tony Crisafi
  • 4
  • 4
9 Comments
 
LVL 13

Expert Comment

by:John Tsioumpris
Comment Utility
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.
0
 

Author Comment

by:Tony Crisafi
Comment Utility
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?

Thanks,

Tony
0
 

Author Comment

by:Tony Crisafi
Comment Utility
This is the code i have so far.

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

   
    rs_PI.MoveFirst
    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
    Else
        OLE_GHS_Pict1.PictureData = rs_PI("GHS_Pict")
    End If
   
    rs_PI.Close

But it come up with a run time error. Bit map you specified is not a device independent bitmap.
0
 
LVL 13

Assisted Solution

by:John Tsioumpris
John Tsioumpris earned 500 total points
Comment Utility
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...
New-Microsoft-Access-Database.zip
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Tony Crisafi
Comment Utility
I'm using Access 2007. I cant see any images in the report?
0
 
LVL 13

Expert Comment

by:John Tsioumpris
Comment Utility
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
0
 
LVL 13

Accepted Solution

by:
John Tsioumpris earned 500 total points
Comment Utility
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.
db1.zip
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
Look at my article Images on continuous forms
In report you can use same technique
0
 

Author Comment

by:Tony Crisafi
Comment Utility
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?

Tony
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
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…
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…

743 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

15 Experts available now in Live!

Get 1:1 Help Now