Question Trouble displaying attachment

darthcalis

Registered User.
Local time
Today, 12:26
Joined
Mar 20, 2012
Messages
17
Hello,

Just wondering if I'm missing something obvious.

I have an unbound attachment field on a report which I use to display a company logo. The logo is a bmp file stored as an attachment in the database so that the client can change it any time they wish.

The code fires in the OnFormat event of the page header of the report. Problem is how to display the logo. This code works fine:

Code:
Me.attLogo.PICTURE = modUtils_GetDBDir() & "\Icons\" & rstLogo!FileName

...where modUtils_GetDBDir() is getting the DB directory for me. But I would think there is a way to just display the logo from within the database, without having to resort to specifying the file? I have tried this:

Code:
Me.attLogo.PictureData = rstLogo!FileData

...but I keep getting an error telling me the file isn't a DIB file! Tbh, I never heard of a DIB before today.:)

Do I have to convert my BMP to a DIB? Seems odd to me...think I must be missing something.

Emilio
 
Hi

In 2007 and 2010 versions just use the field of type attachment. The image is stored in the table and displayed directly in the report. The field report should be linked to the source field.

To extract images from attachment field, search on "SaveToFile". See article below to help.

http://www.ribbon01.com/tutoriais/tuto12eng.asp?id=1#inicio

Good study!
 
Thanks Ari.

My God, what a pain! I thought there would be some simple way to do it. I didn't fancy the idea of having to save it just to get it back into the report, so I added a linking ID field between the main data table and the table that holds the logo, so now it's just a bound control in the report. Seemed simpler. :)

Bizzarely though, although it worked fine for a couple of days, the logo then stopped appearing. I had to delete it from the table, exit the database, re-open it, re-add the logo to the table and then it finally worked again!

Access is a strange beast...
 
Hmm...spoke too soon.

It works until I close the database and open it again. Then the logo bitmap no longer displays in the bound attachment field on the report. I have to go through the same process of deleting it from the table and adding it again, then the logo appears correctly in the report again. Until I close and re-open the database that is, then it stops working again.

Anyone got any ideas?
 

Users who are viewing this thread

Back
Top Bottom