Solved

Dinamically add fields to DataReport

Posted on 2000-03-14
8
158 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 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

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!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

749 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