We help IT Professionals succeed at work.

Dinamically add fields to DataReport

nfernand
nfernand asked
on
194 Views
Last Modified: 2010-05-02
Can I dinamically (in runtime of course) add fields to Data Report? How?
Comment
Watch Question

I don't think that you can add or remove controls at runtime but what you can do is dynamicaly bind a report to a recordset and through code change the caption of the labels on your report.

eg.

Set rptTest.DataSource = rsEmp

rptTest.Sections(1).Controls(1).Caption = "Employee activities for given time period."
   
    rptTest.Sections(3).Controls(1).DataField = "empName"
    rptTest.Sections(3).Controls(2).DataField = "pTitle"
    rptTest.Sections(3).Controls(3).DataField = "wDate"
    rptTest.Sections(3).Controls(4).DataField = "wDesc"

rptTest.Show
rptTest.PrintReport

---------------------------------------

You just have to set the datafield property of the control = to a field in the recordset.

Author

Commented:
Thanks for your answer....

If the initial recordset has two fields and the NEXT binding recordset has 4 fields, Do I get the 2 additional fields into the DataReport?
Do you want to use 2 recordsets on the same report?

Author

Commented:
More or less... I want to create a "Model" Report to share with many recordsets.

Author

Commented:
..but not simultaneously.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Ok.. that's what I've though, but now I'm sure.... thanks man.
No problem
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.