Binding DataReport (in VB6) to custom recordset

Visual Basic Programming Question

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?

Default Text
 

Verified Answer?

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

by:Posted 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
     
     

This content is available to Experts Exchange members

See the answer now
with your Free 30 Day Trial

Get unlimited access to solutions & experts

  • 4,169,477 solved questions
  • 3,805 articles & videos
  • 15,413 tech experts

Get Access Now

Need a customized answer?
Ask your question for one-on-one assistance. We will email you when an expert has commented on your question.

We will never share this with anyone.

201505-LO-Qu-054

Experts Exchange members save,
on average, 2.5 hours per week.

- 2014 EE Annual Survey

Related Questions We have nearly 4 million solutions here.

See More Visual Basic Programming Solutions

Experts Exchange powers the growth and success
of technology professionals worldwide.

  • Solve

    Experts Exchange is the tech professional’s trusted, on-demand resource for solving difficult problems, making informed decisions, and delivering excellent solutions.

  • Learn

    With unparalleled access to technical experts, verified real-world solutions, and diverse educational content, Experts Exchange enables personalized development of technology skills.

  • Network

    Experts Exchange gives you the professional exposure and valued relationships key to building the career you want.

Join the Network Today

See Plans and Pricing