Data Report - Parameters/Variables

Posted on 1999-07-26
Medium Priority
Last Modified: 2010-04-30
I am trying to make reports using VB6's new Data Report Designer.  All of the examples I have seen (using DRD) have involved binding all data related controls to a command object in a Data Environment Designer.  Furthermore, I have yet to find an example or explanation of how to manually create a report by setting values to labels and textboxes at run-time.
I would like to generate a report using user-provided information (passed variable), NOT data resulting from bound controls.

If the Data Report is unable to fulfill these requirements, is there another Report Designer (no Crystal Reports [agh!], please!) that could?
Question by:CArnold
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

Expert Comment

ID: 1527578
You can affect some aspects of the Data Report at run time - I've altered lables doing this. You have to access them through the collections for the section they are in. I haven't gone into it more than that as I get tired of generating ewrrors due to the fact that MS cannot be bothered to produce decent reference material for this feature!

Accepted Solution

scottsch earned 100 total points
ID: 1527579
The Data Report Designer, IMHO, is not quite a finished product.

A very similar product, that is wonderful, is ActiveReports by DataDynamics. (ActiveReports was awarded VBPJ's Readers' Choice Merit Award at VBITS in San Francisco) It is implimented as an ActiveX Designer.

You can use it and manipulate it just as a form (accessing other forms...), pass it SQL statements, etc.

Unfortunately it has a price tag of $289, but worth every penny in ease of use and flexability...
A must have...


Author Comment

ID: 1527580
I have found the answer to my question!
After toying around with it for a while, I've finally figured out how to manipulate the properties of the Data Report controls!  Here is how:

DataReport1.Sections(3).Controls.Item(1).Caption = "Hi!"

Section(3) = Details section of Data Report.  The Details section of the report is enumerated as "1" when you look at the form in design view.  Disregard how they're numerically indexed in the form's design view.  You will have to find out each section on it's own.  

Item(1) = You will have to know the object's index number to reference it.  Give all objects a unique name (of course) to later identify their index ID (I'll explain later how to do this)

Create a project consisting of one form and one Data Report.
Insert a varying number of controls into each section of the Data Report (i.e. – Place 1 control in the page header, place 2 in the details section, place 3 in the report header, etc.)
Make a simple form containing a command button and a textbox.  For this explanation, I will be using default control names.  In the click event for the command button, insert the following code:

Private Sub Command1_Click()
Dim x As Integer
x = Val(Text1.Text)
     MsgBox DataReport1.Sections(x).Controls.Count
End Sub

Enter a number in the text box and click the command button.  The number you enter will represent the section you are obtaining a control count.  The returned control count will reflect the number of controls for that section (i.e. – If you placed 3 controls in the Details section and the returned  count value is 3, the number you entered into the textbox is the section index for Details)


Dim x As Integer
Dim y As Integer

    x = DataReport1.Sections(3).Controls.Count
    For y = 1 To x
        Debug.Print "Index(" & y & ") = " & _
    Next y

Substitute “Sections(3)” with the appropriate section number.

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 2765257
yuou can pass data to labels by writing a sql at datrareport_initialize containing the data regarding for labels as we do for bound controls.
then do as follow;
datareport.Sections ("<name of section where you want label>").Controls("<label name>").Caption = recordset.coulumns(<column name>).value
LVL 10

Expert Comment

ID: 6799810
Hello CArnold,

It looks like your e-mail address er.... "elsewhere"..... is no longer valid. Would you mind sorting that?



Author Comment

ID: 6801136
Sorry about that Pino.  It has been updated.


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

719 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