Dinamically add fields to DataReport

Can I dinamically (in runtime of course) add fields to Data Report? How?
LVL 2
nfernandAsked:
Who is Participating?
 
tkuppinenConnect With a Mentor Commented:
Create your report with the maximum number of controls you will need and then using the code above you can change the data field property of the textboxes, captions of labels, and the visible property of controls you don't need.  Give this a shot and let me know if you need anymore help or if anything isn't clear.

0
 
tkuppinenCommented:
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.
0
 
nfernandAuthor 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?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
tkuppinenCommented:
Do you want to use 2 recordsets on the same report?
0
 
nfernandAuthor Commented:
More or less... I want to create a "Model" Report to share with many recordsets.
0
 
nfernandAuthor Commented:
..but not simultaneously.
0
 
nfernandAuthor Commented:
Ok.. that's what I've though, but now I'm sure.... thanks man.
0
 
tkuppinenCommented:
No problem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.