Binding DataReport (in VB6) to custom recordset

    Question by:
    On

    Topics:

    I nave designed a report using DataReport designer in VB6 (NOT Crystal). This report is bound to some DataEnvironment in design time. I want to bind my report in runtime to my custom ADODB.Recordset (having just the same structure) How to do it?

    Good Question?
    0
     

    ?

    The member who asked this question verified this comment provided the solution that solved their problem.

    Accepted Solution on 1999-03-24 at 21:45:12ID: 1500665

    4 ways to skin this cat that I can think of:

    Way #1:

    'The path of least resistance'

    Step 1:

    Create your commands in the data environment.

    Step 2:

    Create a DataReport based on these commands.

    Step 3:

    Find out what the entire SQL statement looks like for your commands (In ADO child command's SQL is embedded into the parent's SQL using the SHAPE command)

    Dim myCmd as Command

    For each myCmd in DataEnvironment1.Commands
       If myCmd.Name = "[Insert the name of your parent command here]" Then
          Debug.Print myCmd.CommandText
          Exit For
       End IF
    Next myCmd

    Step 4:

    Determine what it is you want to change about this command or sub-commands and locate those spots in the command text.

    Step 5:

    Write a report-printing routine

    Now you can write a routine that replaces the command text in the parent command with the changes you wanted to make.

    That routine might look something like this....

    SAMPLE CODE:

    Public Sub PrintThatReport(Optional Byval CompanyID as String)

       Dim myRpt as DataReport
       Dim myCmd as Command

       If CompanyID <> "" Then
          Set myRpt = New CompanyReport

          For Each myCmd In DataEnvironment1
             If myCmd.Name = "cmdCompany" Then
                myCmd.CommandText = "SELECT tblCompany.* FROM tblCompany WHERE tblCompany.fldCompanyID = '" & CompanyID & "'"
                myCmd.Execute
                myRpt.Refresh
                myRpt.Show
                Exit For
             End If
          Next myCmd
       Else
          myRpt.Show
       End If

    End Sub
         
         

    Top Expert Contributor

    Essential articles and videos from the Experts

    More valuable questions with Expert answers

    201511-LO-Qu-074

    Extend your technology team with the Experts Exchange community.

    — trusted by —

    Who answers my questions?Our community has technology experts around the world.

    Rgonzo1971

    1

    Articles

    2,116

    Solutions

    Expert in:

    • MS Excel
    • MS Office
    • MS Word
    • VB Script
    • Visual Basic Classic

    Robberbaron (robr)

    1,158

    Solutions

    Expert in:

    • MS Excel
    • VB Script
    • Visual Basic Classic
    • .NET Programming
    • Exchange

    ProfessorJimJam

    613

    Solutions

    Expert in:

    • MS Excel
    • MS Office
    • Spreadsheets
    • VB Script
    • Visual Basic Classic

    David Johnson, CD, MVP

    5

    Articles

    7,112

    Solutions

    Expert in:

    • Microsoft OS
    • Windows 7
    • Windows Server 2008
    • .NET Programming
    • ASP.NET

    sktneer

    362

    Solutions

    Expert in:

    • MS Excel
    • MS Office
    • Visual Basic Classic

    Excel amusant

    170

    Solutions

    Expert in:

    • MS Excel
    • VB Script

    Éric Moreau

    2

    Articles

    10,368

    Solutions

    Expert in:

    • .NET Programming
    • Visual Basic.NET
    • C#
    • Visual Basic Classic
    • ASP.NET

    Robert Schutt

    1,241

    Solutions

    Expert in:

    • JavaScript
    • .NET Programming
    • Visual Basic.NET
    • ASP.NET
    • C#

    Saqib Husain, Syed

    2,436

    Solutions

    Expert in:

    • MS Excel
    • MS Office
    • MS Applications
    • VB Script
    • Visual Basic Classic

    RELATED TOPICS view all topics

    1. MS Excel
      (125,125)
    2. VB Script
      (35,485)
    3. MS Access
      (214,031)
    4. .NET Programming
      (131,107)
    5. Visual Basic.NET
      (91,436)
    6. MS Development
      (48,690)
    7. Programming Languages
      (19,578)
    8. Programming
      (51,621)
    9. MS Office
      (55,911)
    10. MS Word
      (26,636)