Results 1 to 8 of 8

Thread: [RESOLVED] New To DataReport Designing

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Resolved [RESOLVED] New To DataReport Designing

    How do you transfer data from a form that accesses 2 different recordsets to a printed report using vb6 datareport.

    ie rsCustomer and rsBookings
    1 ------> many

    rsBookings is a child of rsCustomer linked by Reference Number.

    I have tried doing it via the dataenvironment, but it only gives me access to one record set, ie rsCustomer when I need access to both recordsets.

    Any help would be appreciated.

    Computerman.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: New To DataReport Designing

    There are several ways, depending on the situation.

    1. Use an "Inner Join" in the SQL statement of the DE
    2. Add a "Child" command to the DE an set the "relation" value.
    3. Create a new recordset from the two other recordsets and assign it as the reports DataSource at runtime.

    hope this helps

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: New To DataReport Designing

    Many thanks for that. I thought there might have been a more efficient way of transfering the data without having to create another recordset.

    If I was to use the DE for my SQL statement, how would I pass the variable ReferenceNumber from the form to the SQL statement?

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: New To DataReport Designing

    This is a DE SQL example
    Code:
    select distinct mid(apn,1,6) as apnmap,apn from lots where mid(apn,1,6)>=? and mid(apn,1,6)<=? order by apn
    The "?" is used to indicate a parameter. Use the "Parameter" tab to name them.

    Then when you call the report

    Code:
    If deApnmap.Recordsets.Item(1).State = adStateOpen Then
                deApnmap.Recordsets.Item(1).Close
            End If
            deApnmap.Commands("Command1_Grouping").Parameters("param1").Value = frmUrange!txtStart
            deApnmap.Commands("Command1_Grouping").Parameters("param2").Value = frmUrange!txtEnd
            rptApnmap.Show
    Hope this is clear enough, I just copied an example for one of my app's

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: New To DataReport Designing

    Thank you very much for that as I can now filter a single record from both record sets successfully.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: New To DataReport Designing

    The problem that I am now having is that when I pass a different value for ReferenceNumber to the query and print the report, I get the previous set of data.

    Code:
    DataEnvironment1.Commands("Booking").Parameters("ReferenceNumber").Value = frmBookingForm!txtAccountNumber
    DataReport1.Show
    What is required so that I loose the previous data and get the new data into the report.


  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: New To DataReport Designing

    Did you close the DE recordset before printing as I showed in the previous post? If so then please post the code.

    If deLotsdouble.rslots.State = adStateOpen Then
    deLotsdouble.rslots.Close
    End If

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: New To DataReport Designing

    Many thanks for that. I forgot to put that in. It works perfectly.


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