Friends,

VB6
Crystal Reports 9
MS-Access

I am always creating a temporary tables for reports. the report is ok...its working perfect.
I am doing all the calculations in the front end (vb6) and saving those recordset output in a table and i am just displaying it in the crystal reports 9.
Please see the below code and help me on using the loop for the crystal reports without using the temp table.
by the way...is my method correct?

Code:
Private Sub cmdbalrep_Click()
Set cn = New ADODB.Connection
Dim rsbalrep As New ADODB.Recordset

cn.Open "DSN=admn1314"
cn.Execute "delete * from balrep"

balsql = "select [stdentry.brno],[stdentry.stdname],[stdentry.amtobepaid]," _
& "sum([feesdetail.paidamt]) as totpaid from stdentry,feesdetail where " _
& "([feesdetail.delstat]='N') and [stdentry.brno]=[feesdetail.brno] and [stdentry.refundstat]='N' " _
& "group by [stdentry.brno],[stdentry.stdname],[stdentry.amtobepaid]"

rsbalrep.Open balsql, cn, adOpenDynamic

Do While Not rsbalrep.EOF
    snoval = snoval + 1
    brnoval = rsbalrep("brno")
    stdnameval = rsbalrep("stdname")
    
    amtbpaidval = Format(rsbalrep("amtobepaid"), "###,###,###")
    totpaidval = Format(rsbalrep("totpaid"), "###,###,###")
    
    balval = amtbpaidval - totpaidval
    
    If balval = 0 Then
    balval = 0
    Else
    balval = Format(balval, "###,###,###")
    End If
    
    cn.Execute "insert into balrep values ('" & snoval & "','" & brnoval & "','" & stdnameval & "'," _
    & "'" & amtbpaidval & "','" & totpaidval & "','" & balval & "')"
    
    rsbalrep.MoveNext
Loop

rsbalrep.Close
Set rsbalrep = Nothing

cn.Close
Set cn = Nothing

    Report1.DiscardSavedData
  
    With crview
        .ReportSource = Report1
        .ViewReport
        While crview.IsBusy
            DoEvents
        Wend
        .Zoom "100"
        .Visible = True
    End With

    
Set Report1 = Nothing
Set cn = New ADODB.Connection
cn.Open "dsn=admn1314"
      
cn.Execute "delete * from refrep"

cn.Close
Set cn = Nothing
End Sub
thanks