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

Dinamically add fields to DataReport

Can I dinamically (in runtime of course) add fields to Data Report? How?
0
nfernand
Asked:
nfernand
  • 4
  • 4
1 Solution
 
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
 
tkuppinenCommented:
Do you want to use 2 recordsets on the same report?
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!

 
nfernandAuthor Commented:
More or less... I want to create a "Model" Report to share with many recordsets.
0
 
nfernandAuthor Commented:
..but not simultaneously.
0
 
tkuppinenCommented:
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
 
nfernandAuthor Commented:
Ok.. that's what I've though, but now I'm sure.... thanks man.
0
 
tkuppinenCommented:
No problem
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now