Displaying multiple images in an Access 2000 report

G

Guest

Greetings one and all,

I'm stuck! I'm attempting to design a report that displays multiple
user-selected images which correspond to individual records. The code below
is as close as I've been able to get, but it only repeats the first image for
every record in the recordset. Any help would be most appreciated.

Private Sub Report_Activate()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim lidx As Long
Dim strPath As String

Set db = CurrentDb

strSQL = "SELECT * FROM tblVisuals " & "WHERE nfldidxItems = " & lidx & ""
lidx = Me!idxItems
strPath = tfldImagePath

Set rs = db.OpenRecordset(strSQL)

With rs
Me!imgItem.Picture = (strPath)
End With

rs.Close

End Sub
 
J

J. Goddard

Hi -

You have the right idea - but what you want to do is reset the image for
each record you print, so your code should be in the "on Format" event
of the Detail section of the report, so that it runs for each record.

But your code does not look right - you open the recordset 'rs', but you
never use anything from it.

questions:

What is the record source for your report? Why not make a query joining
your report's recordsource table and the tblvisuals table, and include
the picture file name as part of the query; this will give you the
picture file name without an additional retrieval.

What is the field name of the picture file in the tblvisuals table?

John
 
G

Guest

Thank you very much for your help.

The record source for my report is a query that is based on two tables:
tblItems and tblVisuals. [tblItems.idxItems] is joined to
[tblVisuals.nfldidxItems].
The user-selected image's path is stored in [tblVisuals.tfldImagePath],
which is passed to the graphic display control in a subform. This allows the
user to change which image is displayed for each record, directly from the
subform.

I also tried using:

Do Until rs.EOF
Me!imgItem.Picture = (strPath)
rs.MoveNext
Loop

But that wouldn't display any image at all.
 
P

Peter YangMSFT]

Hello,

You could use the following method to show the picture dynamically in a
report according to the file path stored in a table.

1. Add a query or table to get the information you want to show in the
report including the file path of the images

2. Add a new report and bind it to the above query/table, drag the field in
the query/table hosting the image path to a textbox (textbox1), and
configure the textbox Visible to false.

3. Add the image control the report

4. Use the following code to get the file path of the image control
dynamically.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me!Image0.Picture = Me!Textbox1.text
End Sub

You may want to refer to the following articles for more related
information:

210100 How to display an image from a folder in a form or in a report in
Access 2000
http://support.microsoft.com/default.aspx?scid=kb;EN-US;210100


286459 How to embed a bitmap object in a report at run time in Access 2002
http://support.microsoft.com/default.aspx?scid=kb;EN-US;286459

If you have any comments, please feel free to let's know. Thank you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter YangMSFT]

Hello,

I'm still interested in this issue. If you have any comments or questions,
please feel free to let's know. We look forward to hearing from you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

JB

Well, since you asked, my question is very simple. I am simply wanting to
use VBA to properly reference an image object inside of a report.

Let's say I have a report called rptImgReport.
From my "Open" event of this report I have the following code.

This does not work below.
Private Sub Report_Open(Cancel As Integer)
Report_rptImgReport.Image143.Picture = "C:\MyImage.jpg"
End Sub


I cannot reference the "Picture" property this way. I've spent a couple of
hours on this and even looked through the Object Browser - and I cannot seem
to reference it. I'm not new to VBA and I'm in MS Access 2003. I can get
the Report.Picture property, but the image control on the report - no go.
I'm sure it's something simple and I'm just not seeing it. Thanks!
 
J

JB

Actually, I figured it out. I got a tip from this forum -
http://www.tek-tips.com/viewthread.cfm?qid=289543 - Although for me it still
didn't work exactly, it gave me a clue as to how to back into the solution.
I simply investigated an image that was on the form where the Picture
property was hardcoded in. Then I threw up some message boxes to see if I
could get to the properties of that image. Once I did that, I was then able
to figure out how to put data in it and viola. This if for MS Access 2003 so
I'm not sure if it is different in 2000. Hope this helps someone. I also
added this to a new thread with the same title. I didn't mean to intrude on
this post that was already going. Charge it to my head and not my heart! I
will place this code inside the OnFormat event, but it did work for OnOpen as
well.

Private Sub Report_Open(Cancel As Integer)
Me.Image0.Properties("Picture").Value = "C:MyImage.JPG"
Me.Image0.Properties("PictureType").Value = 1
Me.Image0.Properties("PictureAlignment").Value = 1
Me.Image0.Properties("SizeMode").Value = 0

End Sub

JB said:
Well, since you asked, my question is very simple. I am simply wanting to
use VBA to properly reference an image object inside of a report.

Let's say I have a report called rptImgReport.
From my "Open" event of this report I have the following code.

This does not work below.
Private Sub Report_Open(Cancel As Integer)
Report_rptImgReport.Image143.Picture = "C:\MyImage.jpg"
End Sub


I cannot reference the "Picture" property this way. I've spent a couple of
hours on this and even looked through the Object Browser - and I cannot seem
to reference it. I'm not new to VBA and I'm in MS Access 2003. I can get
the Report.Picture property, but the image control on the report - no go.
I'm sure it's something simple and I'm just not seeing it. Thanks!

"Peter YangMSFT]" said:
Hello,

I'm still interested in this issue. If you have any comments or questions,
please feel free to let's know. We look forward to hearing from you.

Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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