filter for report image

G

Guest

I have successfully set up a report based on the info "Displaying Images in a
Microsoft Access Report" using a list of 16 gif files for this one report.
Now, I want to do something similar and am not sure if possible or how to get
code to work.

I have several reports that have drawings included and want to save them in
file outside db and link to them. I have a table created with fields
"ReportName" and "ImagePath". I want to list all the reports with paths in
this one table and then create a report with the Image Frame for each report,
but filter the report to the path I need. I wanted to work straight from
table without having to build a query for each report.

Any direction is greatly appreciated.
Thanks in advance,
Pam
 
K

krissco

Pam,

If I understand you correctly your report's data source is a table
(lets call it tblImages). This table has two fields (rptName,
imgPath). You want to be able to show the image at that path for each
report name. You will be able to filter this report the same as any
other report.

If that is correct, then the following should work for you:
Add three controls to your detail section. Two text boxes (one for
rptName, one for imgPath) and one image frame (unbound). Lets call the
image frame "myImage."

In the report module, insert the following code:

Private Sub Detail_Format(CANCEL As Integer, FormatCount As Integer)
Me.myImage.Picture = Me.imgPath
End Sub

I believe that this code will fail for .PNG, .TIFF, .JPG, and .GIF
files. To outfit Access with GDI+ capabilities, check out Stephan
Lebans' amazing code: http://www.lebans.com/loadjpeggif.htm

If you end up using his modules, change the code I supplied to:
Private Sub Detail_Format(CANCEL As Integer, FormatCount As Integer)
Me.myImage.Visible = fLoadPicture(Me.myImage, Me.imgPath)
End Sub


Good Luck,

-Kris
 
G

Guest

Kris,

Thank you for the reply. I can get the report to open to image without the
text boxes using either the report filter or recordsource and specifying the
report name I need, but I can't get it to filter for two images to make a two
page report. I'm using: ReportName="Decontaminationpg1 and this gives the
image I need.

If I enter ReportName="Decontaminationpg1" AND ReportName = "Decontamination"
or (ReportName="Decontaminationpg1") and (ReportName = "Decontamination"),
I get error message "Run-time error 2427: You entered an expression that has
no value."

Do you have any other suggestions?
Pam
 
K

krissco

If I enter ReportName="Decontaminationpg1" AND ReportName = "Decontamination"
or (ReportName="Decontaminationpg1") and (ReportName = "Decontamination"),
I get error message "Run-time error 2427: You entered an expression that has
no value."

That filter is bogus. ReportName="Decontaminationpg1" AND ReportName =
"Decontamination" will always return false. Be careful when using OR
in filters - specify plenty of parentheses to make sure the criteria
are evaluated like you want them to be.

For both reports, use the following filter:
(ReportName="Decontaminationpg1" OR ReportName = "Decontamination")

-Kris
 

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

Similar Threads


Top