Results 1 to 4 of 4

Thread: [RESOLVED] Dynamic Data Reports

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    66

    Resolved [RESOLVED] Dynamic Data Reports

    Can Anyone HELP me in Data Reports. My Prob. is to display Grouped Report at runtime... without using DataEnviornment....
    Thanks in Advance

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dynamic Data Reports

    Does this help?

  3. #3
    Member Dennis DVR's Avatar
    Join Date
    Jul 2005
    Location
    Manila Philippines
    Posts
    54

    Re: Dynamic Data Reports

    Quote Originally Posted by Hack
    Does this help?
    I believe he wants to avoid the use of DataEnvironment and he wants it to be unbound or runtime

    You could use an ADO recordset object, but since DataReport need to have a group section you are going to use the ADO SHAPE command for this matter not just a normal SELECT statement.

    You will need to use the MSDataShape provider and another provider which will be your Data Provider.

    The tree level of your hierarchical recordset will be based on the number of group section in your designer, but bear in mind that datareport does not support multi hierarchical recordset, meaning there should always be 1 child recordset per tree level.

    Here's is what I meant
    Code:
    Multi Hierarchical -> not supported
    Parent
      |
       ----Child
      |
       ----Child -> Same level. This is not allowed as long as the datareport designer is concern.
    
    Hierarchical -> supported
    
    Parent
      |
       ----Child
            |
             ----Grand Child -> inner level
    If you are not familiar with ADO SHAPE COMMAND perhaps this ADO SHAPE TUTORIAL could help.

    ok I found an old code in my HD perhaps it can give you some shed and will get you started
    VB Code:
    1. Private Sub DataReport_Initialize()
    2.     Dim cnn As String
    3.     Dim rs As ADODB.Recordset
    4.     Dim rsChild As ADODB.Recordset
    5.     Dim strSQL As String
    6.     Dim xx As Integer
    7.     Dim yy As Integer 'Additional counter for fields
    8.     cnn = "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\..\Demo.mdb"
    9.     Set rs = New ADODB.Recordset
    10.     Set rsChild = New ADODB.Recordset 'Child recordset
    11.     strSQL = "SHAPE {SELECT Members.MemberID, MemberName, DateMember, Rank FROM Members ORDER BY Members.MemberID} AS Parent "
    12.     strSQL = strSQL & "APPEND ({SELECT * FROM MemberPost} AS Child RELATE MemberID TO MemberID) AS Child"
    13.     'This time we have Parent and Child recordset
    14.     'Members.* - Parent
    15.     'MemberPost - Child
    16.     '   |
    17.     '   -rsChild.*
    18.     rs.Open strSQL, cnn, adOpenForwardOnly, adLockReadOnly, adCmdText
    19.     If Not rs.EOF And Not rs.BOF Then 'Check for empty recordset
    20.        Set DRTutorial.DataSource = rs 'set the data source of our report to rs recordset
    21.        'Populate our textboxes control in the group section with parent recordset
    22.        With DRTutorial.Sections("Parent") 'bind the textboxes in the Group section
    23.             'we need additional counter coz we have placed the detail heading under the group header
    24.             'and this cost us additional control so the count of our control inside the Group header is bigger than the count of our field
    25.             For xx = 1 To .Controls.Count 'loop through controls under the Group section
    26.                If TypeOf .Controls(xx) Is RptTextBox Then 'is it textbox control
    27.                   .Controls(xx).DataField = rs.Fields(yy).Name 'yes, so we need to bind it
    28.                   yy = yy + 1
    29.                End If
    30.             Next
    31.        End With
    32.        'This is where our child recordset goes
    33.        With DRTutorial.Sections("Child")
    34.           Set rsChild = rs.Fields("Child").Value 'our Child recordset is in the last field of our rs recordset
    35.           'Access all the controls in this section and bind the textboxes to a child recordset
    36.           For xx = 1 To .Controls.Count
    37.               If TypeOf .Controls(xx) Is RptTextBox Then 'is it textbox control
    38.                  'Start at field 1 to ignore the MemberID field we don't want it to appear in the detail section
    39.                  .Controls(xx).DataField = rsChild.Fields(xx).Name 'bind it
    40.                  'set the datamember to our child recordset
    41.                  .Controls(xx).DataMember = rs.Fields("Child").Name 'we need to set the datamember to point to our child recordset
    42.               End If
    43.           Next
    44.           'Bind it regardless of the value of chkWithTotal
    45.           DRTutorial.Sections("ParentFooter").Controls("Function1").DataMember = rs.Fields("Child").Name
    46.           DRTutorial.Sections("ParentFooter").Controls("Function1").DataField = rsChild.Fields(0).Name
    47.           DRTutorial.Sections("ReportFooter").Controls("Function2").DataField = rsChild.Fields(0).Name
    48.           rsChild.Close 'we are safe to close the recordset
    49.           Set rsChild = Nothing 'release the object from memory
    50.        End With
    51.        If frmStep4.chkWithTotal.Value <> vbChecked Then 'Hide the total post and post count when chkWithTotal is not checked
    52.           DRTutorial.Sections("ParentFooter").Controls("lblPostCount").Visible = False
    53.           DRTutorial.Sections("ReportFooter").Controls("lblTotalPost").Visible = False
    54.           DRTutorial.Sections("ParentFooter").Controls("Function1").Visible = False
    55.           DRTutorial.Sections("ReportFooter").Controls("Function2").Visible = False
    56.        End If
    57.        DRTutorial.Refresh 'refresh the datareport to update changes
    58.        DRTutorial.WindowState = vbMaximized
    59.     End If
    60.     rs.Close
    61.     Set rs = Nothing
    62. End Sub

    PS: It is an old code, so it might not be optimized
    Last edited by Dennis DVR; Aug 21st, 2005 at 02:10 AM.

  4. #4
    Member
    Join Date
    May 2009
    Posts
    55

    Re: Dynamic Data Reports

    Quote Originally Posted by Hack View Post
    Does this help?
    It's need a subscription.
    Can you copy it here ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width