?
Solved

Dinamically add fields to DataReport

Posted on 2000-03-14
8
Medium Priority
?
167 Views
Last Modified: 2010-05-02
Can I dinamically (in runtime of course) add fields to Data Report? How?
0
Comment
Question by:nfernand
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 1

Expert Comment

by:tkuppinen
ID: 2617052
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
 
LVL 2

Author Comment

by:nfernand
ID: 2617519
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
 
LVL 1

Expert Comment

by:tkuppinen
ID: 2619574
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!

 
LVL 2

Author Comment

by:nfernand
ID: 2619824
More or less... I want to create a "Model" Report to share with many recordsets.
0
 
LVL 2

Author Comment

by:nfernand
ID: 2619829
..but not simultaneously.
0
 
LVL 1

Accepted Solution

by:
tkuppinen earned 200 total points
ID: 2619940
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
 
LVL 2

Author Comment

by:nfernand
ID: 2620673
Ok.. that's what I've though, but now I'm sure.... thanks man.
0
 
LVL 1

Expert Comment

by:tkuppinen
ID: 2620746
No problem
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question