trouble displaying image in report

L

lord.zoltar

Hello,
I'm a bit new to Access and I'm working on a report that is supposed to
display an image for each record. The image itself is not stored, only
the path to it. I've been looking for a while now for code that will
display an image when the report is loaded, and most of it does not
work :(
I found some code that I think should be added to the report Detail's
"On format" event:

If [gImage] <> "" Then
Me![g_img].Picture = [gImage]
End If

But I get an error that the field "gImage" could not be found.
"gImage" is the image path in the table, and "g_img" is the PictureBox
control on the report.
Any ideas why this is happening?

I've worked with VB .NET a little, but never before with Access, so it
might just be a syntax issue - I admit I'm confused by the "Me!" and I
don't know why the example code I've seen suggested putting the name of
the control in square brackets (I thought that was only for names of
database fields).

Thanks!
 
L

lord.zoltar

Ok, I got it working:

If Me.gImg_text <> "" Then
Me.g_img.Picture = Me.gImg_text
End If

"gImg_text" is an invisible text box bound to the gImage field... It
works but it seems kind of ugly and hack-ish. Is there any way to bind
the picture directly to the stored path? ... or any better way to do
it?

Also, another related question!
I know that no image will be larger than a certain dimension (400x400),
but an image could be any size smaller. How would I go about finding
the dimensions of the image file so I can resize the picture box
(instead of scaling the image to fit)?

thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top