• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4120
  • Last Modified:

how to dynamicaly load picture in datareport (vb6)

In have a data report in vb6.
In db I have field say image_path.
I want to load images in datareport dynamically(runtime) whose path is specified by the field image_path

Please guide.(vb6 datreport only)
0
Maverick_Cool
Asked:
Maverick_Cool
  • 9
  • 5
  • 2
  • +1
1 Solution
 
3_SCommented:
use
Set DataReport1.Sections("Section1").Controls("Image1").Picture = LoadPicture("c:\test.jpg")

everything between "" must be adapted to your report.
Change DataReport1 to the name of your report.
You must have already placed a rptimage on your report otherwise you must add this also dynamically.
0
 
Maverick_CoolAuthor Commented:
the problem is LoadPicture("c:\test.jpg")
as this path will come from db.

0
 
Maverick_CoolAuthor Commented:
file location is a column in db which will in datasource for the datareport.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
3_SCommented:
Are you using ADO?
if you use a recordset if could look something like

Set DataReport1.Sections("Section1").Controls("Image1").Picture = LoadPicture(rs.fields("image_path"))

I don't know how you can do this at runtime if you use a dataenvironment for the datareport.
But I always first select the data from the database, link this to the datareport. This way you can work more dynamically.

as example
            Load DataReport1
            Set DataReport1.DataSource = RS   'RS contains the recordset
            DataReport1.PrintReport
            'or
            datareport1.Show

Can you explain this a little bit more?
file location is a column in db which will in datasource for the datareport.


0
 
Maverick_CoolAuthor Commented:
datasource is added at runtime
0
 
Maverick_CoolAuthor Commented:
any body??
other wise i am closing the question.
0
 
aikimarkCommented:
How are you adding the data source at run time?  What is the name of the data source?  What is its recordset property?

Generally, you add code in the format or print events of the report to set control properties that aren't bound to a data report recordset field.
0
 
Maverick_CoolAuthor Commented:
well report is loaded,I run database query the resuttset is added to datasource of datareport. I have column which tell the path of the pic file, which needs to be loaded

0
 
aikimarkCommented:
I double-checked my earlier comment and discovered that I was wrong.  The VB6 DataReport does not have an event that fires with each record.  I'm changing my recommendation to "It can't be done."
0
 
Maverick_CoolAuthor Commented:
so whats the final answer?
0
 
aikimarkCommented:
I'm not sure there is one.

Is it possible to bind your report's picture/image control to a field in the recordsource?  That might give you a solution path, albeit a messy one.  You would need to load the pictures into a table in your database and join that table with your current table set that feeds the report.

If all the pictures are the same size, you might have a post-process solution.  Write the report out to a PDF file and then process the PDF file with code, replacing the images.  Then print the report.

Those may be your only possible solution paths to explore if you are stuck with the DataReport.  If you have MS-Access, you could use its reporting engine, which DOES have events that fire with every page printed.  It looks a lot like the DataReport.  Or you could replace the DataReport with some other reporting tool.

0
 
Maverick_CoolAuthor Commented:
there must be a way.
i have the file path.
datareport can dynamically load pictures
somw linkage sholude there.
0
 
aikimarkCommented:
>>datareport can dynamically load pictures

What is the source of this statement?
0
 
Maverick_CoolAuthor Commented:
Set DataReport1.Sections("Section1").Controls("Image1").Picture = LoadPicture(rs.fields("image_path"))

see the msg   ID: 26182327 by 3_S in this thread
0
 
aikimarkCommented:
That statement sets the image property for all pages in the report.  It is not set for each record of the report, which is what you want.
0
 
Maverick_CoolAuthor Commented:
Well, I am not 100% satisfied with the answer. Any this points are for your effort.
0
 
Mohammad Islam SiddiquiComputer Lab Incharge & Guide to students in vb projectsCommented:
Set DataReport1.Sections("Section1").Controls("Image1").Picture = LoadPicture(rs.fields("image_path"))

I tried it but error msg showing that object required ....

i am very tired of this
how to fire image from ms-access database to data report ................
kindly help my project is incomplete for this ........................
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 9
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now