Results 1 to 5 of 5

Thread: Getting data from two recordsets problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Location
    Pakistan
    Posts
    289

    Getting data from two recordsets problem

    Plz help me:
    I displayed data on datareport from two recordsets. Report is also attached. The problem is:
    Date is display twice, i want to display date in once and data should display against the date from both recordset. I used the code
    Code:
         rsFee.Open "SELECT CurrentDate, SUM(DepositedFee) AS `DepositedFee` FROM Fee WHERE month(CurrentDate)= " & cmbMonth.Text & " and year (CurrentDate)= " & txtYear.Text & " GROUP BY CurrentDate order by currentdate", myConn, adOpenKeyset, adLockOptimistic
         rsIncome.Open "SELECT CurrentDate, Sum(Amount) as `Income` FROM tbTransaction WHERE HEAD='INCOME' AND month(CurrentDate)= " & cmbMonth.Text & " and year (CurrentDate)= " & txtYear.Text & " group by currentDate order by currentdate", myConn, adOpenKeyset, adLockOptimistic
    
    '**********************************************************************************
        theRs.Fields.Append "Currentdate", adDate
        theRs.Fields.Append "DepositedFee", adDouble
        theRs.Fields.Append "Concession", adDouble
        theRs.Fields.Append "Total", adDouble
        theRs.Fields.Append "Income", adDouble
        
        
        theRs.Open
        While Not rsFee.EOF
        theRs.AddNew
        theRs.Fields!CurrentDate = rsFee.Fields!CurrentDate
        theRs.Fields!DepositedFee = rsFee.Fields!DepositedFee
        theRs.Update
        rsFee.MoveNext
        Wend
        
        While Not rsIncome.EOF
        theRs.AddNew
        theRs.Fields!CurrentDate = rsIncome.Fields!CurrentDate
        theRs.Fields!Income = rsIncome.Fields!Income
        theRs.Update
        rsIncome.MoveNext
        Wend
        theRs.Sort = "currentdate"
        theRs.MoveFirst
        Set rptMonIncome.DataSource = theRs
        rptMonIncome.DataMember = theRs.DataMember
    
         rptMonIncome.Show
            Unload Me
    Attached Images Attached Images  

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Getting data from two recordsets problem

    You could insert a Group by date, sum the imports and suppress the Detail
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Location
    Pakistan
    Posts
    289

    Re: Getting data from two recordsets problem

    I am sorry, sir, coulnt' understand can u give me detail please

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Location
    Pakistan
    Posts
    289

    Re: Getting data from two recordsets problem

    Can anybody else help me in this regard......

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

    Re: Getting data from two recordsets problem

    Try something like this,

    Code:
        While Not rsIncome.EOF
        theRs.Find "CurrentDate=#" & CStr(rsIncome.CurrentDate) & "#", , adSearchForward, 1
        if theRs.EOF then
            theRs.AddNew
            theRs.Fields!CurrentDate = rsIncome.Fields!CurrentDate
            theRs.Fields!Income = rsIncome.Fields!Income
        else
            theRs.Edit
            theRs.Fields!Income = rsIncome.Fields!Income
        End If
        theRs.Update
        rsIncome.MoveNext
        Wend

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