Solved

Dinamically add fields to DataReport

Posted on 2000-03-14
8
149 Views
Last Modified: 2010-05-02
Can I dinamically (in runtime of course) add fields to Data Report? How?
0
Comment
Question by:nfernand
  • 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
 
LVL 2

Author Comment

by:nfernand
ID: 2619824
More or less... I want to create a "Model" Report to share with many recordsets.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Author Comment

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

Accepted Solution

by:
tkuppinen earned 50 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now