I use vb 6.0 , Sql server and Data report . When i am go to show the report there is a problem.

The Code is following.
Private Sub cmdShow_Click()
On Error GoTo Errorhandler


Dim cn As New ADODB.Connection
' Dim rs As New ADODB.Recordset
' Dim rs1 As New ADODB.Recordset
' Dim rs2 As New ADODB.Recordset
' Dim rs3 As New ADODB.Recordset
Dim rsMargin As New ADODB.Recordset
' 'Dim rsCust As New ADODB.Recordset
' Dim ms As New ADODB.Recordset
' Dim ActualB, SaleB, SaleShare As Double
' Dim diff, i As Integer
' Dim dt As Date
' Dim BalQty As Double
' Dim BalQty1 As Double
' Dim amt As Double
' Dim CurrVal As Double
' Dim StockVal As Double
' Dim totalInv As Double
' Dim saleBale As Double
' Dim Negative As String
' Dim TotalStockval As Double
' StockVal = 0
' totalInv = 0
'
cn.Open frmmain.cnString
cn.CommandTimeout = 0
' 'rsCust.Open "select Customerid from customer", cn, adOpenDynamic, adLockOptimistic
If (rsMargin.State) Then rsMargin.Close
rsMargin.Open "Select MarginLimit from Customer where CustomerID='" & stCustId.Text & "'", cn
'
' If (rs.State) Then rs.Close
'
' rs.LockType = adLockOptimistic
' 'rs.Open "select distinct InstrumentID from BrokerHouseStock where CustomerID='" & stCustId.Text & "' and HowlaDate<='" & dpInDate.Value & "'", cn
' '*********
' rs.Open "select InstrumentID, sum(DepositQty-WithdrawalQty) as AcBal from BrokerHouseStock where CustomerID='" & stCustId.Text & "' and HowlaDate<='" & dpInDate.Value & "' group by InstrumentID", cn
'
'
' Negative = LoadProperty("Negative Client Stock", False)
' rs1.LockType = adLockOptimistic
' rs1.CursorType = adOpenDynamic
'
'
' ms.LockType = adLockOptimistic
' rs3.LockType = adLockOptimistic
'
' ms.Open "delete from CheckDB", cn
' ms.Open "select * from CheckDB", cn
'
' TotalStockval = 0
' amt = getCustomerBal(stCustId.Text, dpInDate.Value)
' Do While Not rs.EOF
' dt = dpInDate.Value
'
' 'cs.Open "select * from Instrument where InstrumentID='" & rs!InstrumentID & "'", cn
' 'bs.Open "select sum(DepositQty-WithdrawalQty) as AcBal from BrokerHouseStock where CustomerID='" & stCustId.Text & "' and InstrumentID='" & rs!InstrumentID & "' and HowlaDate<='" & dpInDate.Value & "'", cn
' 'ActualB = IIf(IsNull(bs!AcBal), 0, bs!AcBal)
'
' ActualB = IIf(IsNull(rs!AcBal), 0, rs!AcBal)
'
' If rs3.State = 1 Then rs3.Close
' rs3.Open "select sum(DepositQty-WithdrawalQty) as SaleBal from BrokerHouseStock where CustomerID='" & stCustId.Text & "' and InstrumentID='" & rs!InstrumentID & "' and ClearingDate<='" & dpInDate.Value & "'", cn
' SaleBal = IIf(IsNull(rs3!SaleBal), 0, rs3!SaleBal)
'
'
' If rs1.State = 1 Then rs1.Close
'
' rs1.Open "select distinct pricedate,InstrumentID,CurrentValue from PriceList where InstrumentID='" & rs!InstrumentID & "'order by priceDate", cn
'
' If Not rs1.EOF Then
' rs1.MoveLast
' CurrVal = rs1!CurrentValue
' Else
' CurrVal = 0
' End If
'
' StockVal = CurrVal * ActualB
' amt = getCustomerBal(stCustId.Text, dpInDate.Value)
' If ActualB = 0 Then
'
' Else
' ms.AddNew
' ms!Instrument = rs!InstrumentID
' ms!ActualBal = ActualB
' ms!SaleBal = IIf(IsNull(SaleBal), 0, SaleBal)
'
' ms!CurrentValue = IIf(IsNull(CurrVal), 0, CurrVal)
' If Negative = "0" Then
' If StockVal < 0 Then
' StockVal = 0
' End If
' End If
' ms!StockValue = IIf(IsNull(StockVal), 0, StockVal)
'
' ms.Update
' totalInv = totalInv + ms!StockValue
' End If
' 'bs.Close
' 'cs.Close
' 'rs1.Close
' rs.MoveNext
' Loop

amt = getCustomerBal(stCustId.Text, dpInDate.Value)

MsgBox "Report Generated ...."
If de.rscmdClientStockPort.State = 1 Then de.rscmdClientStockPort.Close
de.cmdClientStockPort stCustId.Text, dpInDate
'de.cmdSaleSh
drClientStockPort.Sections("ReportHeader").Controls("lblCustomer").Caption = getCustomerName(CStr(stCustId.Text)) & " " & ("(" & stCustId.Text & ")")
drClientStockPort.Sections("ReportHeader").Controls("lblPhone").Caption = getCustomerPhone(CStr(stCustId.Text))
drClientStockPort.Sections("ReportHeader").Controls("lblBO").Caption = getBOID(CStr(stCustId.Text))
drClientStockPort.Sections("ReportHeader").Controls("lblMargin").Caption = CStr(rsMargin.Fields(0) & "%")
If LoadProperty("RatioDisplay", False) = "1" Then
If amt > 0 Then
drClientStockPort.Sections("ReportHeader").Controls("Label17").Visible = True
drClientStockPort.Sections("ReportHeader").Controls("Label17").Caption = Format(totalInv / amt * 100, "#,#0.00")
Else
drClientStockPort.Sections("ReportHeader").Controls("Label17").Visible = True
drClientStockPort.Sections("ReportHeader").Controls("Label17").Caption = 0
End If
Else
drClientStockPort.Sections("ReportHeader").Controls("Label17").Visible = False
drClientStockPort.Sections("ReportHeader").Controls("Label14").Visible = False
End If

drClientStockPort.Sections("ReportHeader").Controls("lblDate").Caption = CStr(Format(dpInDate.Value, "dd-MMM-yyyy"))
If amt < 0 Then
amt = Abs(amt)
drClientStockPort.Sections("ReportHeader").Controls("lblBal").Caption = "Cr:" & Format(amt, "#,#0.00")
Else
amt = amt * (-1)
drClientStockPort.Sections("ReportHeader").Controls("lblBal").Caption = "Dr:" & Format(amt, "#,#0.00")
End If
'drClientStockPort.Sections("ReportFooter").Controls("Labletotal").Caption = Format(totalInv, "#,#0.00")

InitDRHeading drClientStockPort
'drClientStockPort.Sections("ReportFooter").Controls("Labletotal").Visible = True
drClientStockPort.Refresh
drClientStockPort.Show

Exit Sub
Errorhandler:
MsgBox err.Description
End Sub


I do not understand what is the problem.

.................................
I do not understand what is the problem.
...................................

I don't understand all that junk code .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.