Solved

Data Report Designer - Programmatic Control ?

Posted on 2002-04-14
23
306 Views
Last Modified: 2008-02-01
VB6 SP5 EE

I would like to be able to drive the Data Report Designer programmatically.

I can do simple tasks:

If you setup TextBoxes on the DataReport1 and set their DataField property to the name of the field in the rs recordset and then:

Dim MyReport as New DataReport1
Set MyReport.DataSource = rs
MyReport.Show

works and shows the report as expected.

However I cannot get it to work with report sections. I guess this is beacuse the DataMember is not being setup.

However I do not want to setup loads of Commands in a Data Environment Designer.

Has anyone got any examples of code which DIRECTLY (not DataEnvironmentDesigner driven) uses DataReporter using code.

The reason I need this is I build recordsets on the fly using dynamic SQL and although I could create and drop commands I actually have the disconnected recordsets available. All I want to do is use these already available recordsets as a feed to DataReport. I do not want to do work already done twice and the recordsets are already available.

Any help much appreciated.

Thanks in advance.
0
Comment
Question by:Felicitous
23 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 

Author Comment

by:Felicitous
Comment Utility
Hi Eric (Almost 2 yrs since you last helped me out :-) ),

Although I have not seen this one, this is almost what I am doing. The difference here is that the article populates the controls names and I set them up in the design props (even though no data source it still takes a value).

The difficulty I have is not getting it to work on a basic reports. What I need is programmatic grouping of a single flat recordset.

Any ideas ?

Regards,

Graham
0
 

Author Comment

by:Felicitous
Comment Utility
Hi Eric (Almost 2 yrs since you last helped me out :-) ),

Although I have not seen this one, this is almost what I am doing. The difference here is that the article populates the controls names and I set them up in the design props (even though no data source it still takes a value).

The difficulty I have is not getting it to work on a basic reports. What I need is programmatic grouping of a single flat recordset.

Any ideas ?

Regards,

Graham
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 
LVL 1

Expert Comment

by:falconew
Comment Utility
Hi Felicitous,

I don't think single flat recordset complies with the report. You must create the recordset using Parent-child recordset using Shape command.
I have implemented the report using dynamic recordset and so far I don't find any problem.
Let me know if you need any help.

Regards,
Falconew
0
 

Author Comment

by:Felicitous
Comment Utility
Hmmm, cannot use the SHAPE statement without re-coding all the queries which produce a flat recordset as a

Dim rs as ADODB.Recordset

Does this mean it is not possible. I do have a recordset (rs) and could use a SHAPE command to another table referencing the (rs) recordset but how do you use SHAPE on a recordset object and a table rather than a two base tables ?

The MS article only seems to work if you are directly accessing a database. It does not seem to work for in-memory / disconnected recordsets.

The need to use SHAPE seems to unecessarily restrict what you can do with DataReporter, especially if you have disconnected or generated recordsets to deal with.

Regards,

Graham
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
if you need grouping, the Data Report engine requires a SHAPEd recordset. All the recordsets (shaped or not) can be built into memory.

The DataReport is a very limited report engine.
0
 

Author Comment

by:Felicitous
Comment Utility
Can I take two recordsets (both disconnected in memory) and SHAPE them ?

If so how ?

Thanks,

Graham
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
you can't transform your current recordset into a hierarchical recordset but you can build one and fill it. see http://support.microsoft.com/default.aspx?scid=kb;en-us;Q196029
0
 
LVL 6

Expert Comment

by:pierrecampe
Comment Utility
Ping
0
 

Author Comment

by:Felicitous
Comment Utility
Ah ah,

this is starting to look promising :-)

however looking at the code I understand everything (stupid statement!) except...........

We have defined 3 recordsets, one for each level of the hierarchy. I can see how the SHAPE command syntax works and how the SHAPE statement links the recordsets. What I cannot see is how the in store recordsets rsCh and rsGrndCh are "related" (bad term)/attached/made to work/link together.

I guess its around what the following statements do for me:

  Set rsCh = rs("Child").Value

and

  Set rsGrndCh = rsCh("GrandChild").Value


This is something I have never used before. How is this statement actually working. What is it doing, both in english and tech speak please.

For example it is setting the rsCh recordset to the value of the contents of the rs recordsets Child field. Now hows that work, is it a special for Hierarchic recordsets.

I have set recordsets to each other and objects to each other but never set a recordset to a single field. Is this a type of assignment which is not obvious ?

I am interested as I want to understand more about how its working, that way I can be self-sufficient in the future.

This is looking good folks, thanks for all the help.

Kind Regards,

Graham
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Felicitous
Comment Utility
PS.

any quick way of moving the contents of one recordset into another rather than a row by row loop ?

Regards,

Graham
0
 

Author Comment

by:Felicitous
Comment Utility
PS.

any quick way of moving the contents of one recordset into another rather than a row by row loop ?

Regards,

Graham
0
 

Author Comment

by:Felicitous
Comment Utility
PS.

any quick way of moving the contents of one recordset into another rather than a row by row loop ?

Regards,

Graham
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
>>This is something I have never used before. How is this statement actually working. What is it doing,
both in english and tech speak please.

This was introduced by the hierarchical recordset. One of the field of a parent recordset is actually a recordset itself. But the child recordset only contains data related to its parent.

see this example

ORDER1
   ORDER1 ITEM1
   ORDER1 ITEM2
   ORDER1 ITEM3
ORDER2
   ORDER2 ITEM1

ORDERs here are the top level recordset. Lets call it rs. rs.Count is 2 (you have 2 orders).

While on the first order, if you "set rschild = rs("Child").Value", you will get a recordset called rschild which recordcount is 3.

If you use rs.movenext and "set rschild = rs("Child").Value", rschild will now have a recordcount of 1.

0
 

Author Comment

by:Felicitous
Comment Utility
Eric,

Whilst I can SEE what is happening with the set rschild = rs("Child").Value I have to say I dont really understand what VB is doing and how it does it.

To me the statement says set this recordset to a value!

I cant see how (the syntax) says set (an extra field) in the recordset to another child recordset. The syntax seems wrong or is it my lack of understanding again!

Also what happens if we have two child recordsets immediately below the parent. How does the above statement work then? Do I have two fields in the parent recordset that are recordsets. How do I associate the recordsets then cus the statements would be the same would they not ?

Set rsParent = rsChildSet1("ChildSet1sKey in the rsChildSet1").Value
Set rsParent = rsChildSet2("ChildSet2sKey in the rsChildSet2").value

or cant you do this, or am I totally lost ?

ghill@felicitous.com

Regards,

Graham
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
how are your 2 original recordsets filled?
0
 

Author Comment

by:Felicitous
Comment Utility
Original recordsets are filled using a Class which performs database access. However its a simple one and not a true data provider (I dont use bound stuff much).

Bascially I:

Set rs = objData.SelectRecords(True)

The TRUE bit is just saying sorted or not.

The objData class submits a dynamically created (I need this for what I am doing) SQL statement to SQL server via a statement similar to this :

Temprs.Open strSQL, pmConnection, pmADOCursorType, adLockReadOnly

and returns it via the function of return type ADODB.Recordset as a disconnected recordset (I set the other bits to nothing to disconnect it). I dont need to update the recordsets.

Both recordsets are created this way.

I just need

Parent -----
            Child


But was trying to understand if I could

Parent -----
            Childrs1

            Childrs2


?

Thanks for your patience

Graham




0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
Replace the strSQL of

Temprs.Open strSQL, pmConnection, pmADOCursorType, adLockReadOnly

to contain a SHAPE query and your problems will be solved!

You have an example of a SHAPE query in http://support.microsoft.com/default.aspx?scid=kb;en-us;Q289793
0
 

Author Comment

by:Felicitous
Comment Utility
might only partly work.

Firstly the recordset I return gets fed to a Graph in one case and a DataGrid in another.

How would DataGrid or Graph respond to a hierarchic recordset instead of a flat one ?

Secondly the recordsets I want to relate for reporting purposes are either both created seperately like I showed OR in another case a recordset (as prev) and a Table.

I suppose I could get the obj to return two recordsets, one shaped on not, but then work gets done twice.

Is it possible to write the query as a SHAPEd one and then "re-shape" it to add a recordset later. I think I read something about shaping but info seems minimal even in the SDK / SQL Doc and ADO Doc.

Regards, Graham
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
>>Firstly the recordset I return gets fed to a Graph in one case and a DataGrid in another.

You will need to get 2 recordsets : one flat and one shaped.

>>How would DataGrid or Graph respond to a hierarchic recordset instead of a flat one ?

They can't.

>>I suppose I could get the obj to return two recordsets, one shaped on not, but then work gets done twice.

It shouldn't be long. If you are using SQL Server or Oracle, and your queries are called in a short period of time, data may still be in memory.

>>Is it possible to write the query as a SHAPEd one and then "re-shape" it to add a recordset later. I
think I read something about shaping but info seems minimal even in the SDK / SQL Doc and ADO Doc.

You could manually feed a new hierarchical recordset (created in memory) from your 2 recordsets but it will be long because you will need to loop trhough both recordsets and copy fields from the flat recordsets to the hierarchical recordset.
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 300 total points
Comment Utility
any progress?
0
 

Author Comment

by:Felicitous
Comment Utility
Sorry forgot,

have not quite done what I needed, change of priorities caught me. Here are the points, but I may be back for more (another question on the forum) in the next few weeks, when I get back to completing this work.

Thanks for your help.

Kind Regards,

Graham
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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.
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…

728 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

10 Experts available now in Live!

Get 1:1 Help Now