Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    157

    Unanswered: Only last two records shows in MSFlexGrid

    Hi: Can any one please tell me why the grid is showing only the last two records as there are total 5 records in it. Is there any settings are required in the grid. I am running program in debug mode and put my mouse over on each value and they are 5 records but instead of all 5 the grid shows the last two records.i am using MSFlexGrid

    Do While Not rsADO.EOF
    sCurrentBalance = CurrentBalance(i, rsADO!client_name, "" & rsADO!bal_lower, "" & rsADO!bal_upper)
    sCurrentCount = CurrentCount(i, rsADO!client_name, "" & rsADO!bal_lower, "" & rsADO!bal_upper)
    If Val(sCurrentBalance) <> 0 Then
    i = i + 1
    grdDistribution.Rows = i + 1
    grdDistribution.Row = i
    grdDistribution.TextMatrix(i, 1) = rsADO!clientcode ' client code
    grdDistribution.TextMatrix(i, 2) = rsADO!client_name
    grdDistribution.col = 3
    grdDistribution.CellAlignment = 1
    grdDistribution.TextMatrix(i, 3) = rsADO!balance
    grdDistribution.col = 4
    grdDistribution.CellAlignment = 1
    grdDistribution.TextMatrix(i, 4) = rsADO!bal_lower
    grdDistribution.col = 5
    grdDistribution.CellAlignment = 1
    grdDistribution.TextMatrix(i, 5) = "" & rsADO!bal_upper
    grdDistribution.col = 6
    grdDistribution.CellAlignment = 1
    'grdDistribution.TextMatrix(i, 6) = Distribution ' "" & rsADO!Distribution
    grdDistribution.TextMatrix(i, 6) = rsADO!Distribution
    grdDistribution.TextMatrix(i, 7) = sCurrentBalance
    grdDistribution.TextMatrix(i, 8) = sCurrentCount
    End If
    rsADO.MoveNext
    Loop

    Thanks.

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    add a breakpoint to the Do While statement, run the app, and step through the code. Without knowing the data that's in the table, (nor have you posted the currentbalance function,) It looks like the current balance may not be incrementing for the first three records.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Jul 2006
    Posts
    157
    Yes I put a break point and when i checked there are 5 records. The function works fine. I check the grid the three records are in the grid but they hide under the window upper bar because when i press the up arrow key i feel that they are hide under. I dont know where i do the settings so that all three will be shows

    Function CurrentBalance(i As Integer, sClientCode As String, sLower As String, sUpper As String) As String
    Dim rsADO_SQL As ADODB.Recordset
    Dim sqlquery As String
    Dim sDistribution() As String
    Dim fBalance As Single

    If sLower = "ALL" Then
    sqlquery = "SELECT sum(Cur_Bal) as BalanceSum from tbl_Distlist_Dep where (clt_ID = '" & Trim(sClientCode) & "')"
    Else
    If sUpper = "" Then
    sqlquery = "SELECT sum(Cur_Bal) as BalanceSum from tbl_DistList_Dep Where (clt_ID = '" & Trim(sClientCode) & "') and (cur_bal " & sLower & ")"
    ElseIf sLower = "" Then
    sqlquery = "Select sum(Cur_Bal) as BalanceSum from tbl_Distlist_Dep Where (clt_ID = '" & Trim(sClientCode) & "') and (cur_Bal " & sUpper & ")"
    Else
    sqlquery = "Select sum(Cur_Bal) as BalanceSum from tbl_Distlist_Dep Where (clt_ID = '" & Trim(sClientCode) & "') and (cur_Bal between " & sLower & " and " & sUpper & ")"
    End If
    End If
    oDBUtil.OpenADORecordSet sqlquery, cnADOSQL, rsADOSQL, 0, adCmdUnknown
    If IsNull(rsADOSQL!balancesum) Then
    CurrentBalance = 0#
    Else
    CurrentBalance = Format(rsADOSQL!balancesum, "#######.#0")
    End If
    Set rsADOSQL = Nothing

    End Function

    Function CurrentCount(i As Integer, sClientCode As String, sLower As String, sUpper As String) As String
    Dim rsADO_SQL As ADODB.Recordset
    Dim sqlquery As String
    Dim sDistribution() As String
    Dim fBalance As Single

    If sLower = "ALL" Then
    sqlquery = "SELECT Count(Cur_Bal) as BalanceCount from tbl_Distlist_Dep where (clt_ID = '" & sClientCode & "')"
    Else
    If sUpper = "" Then
    sqlquery = "SELECT Count(Cur_Bal) as BalanceCount from tbl_DistList_Dep Where (clt_ID = '" & sClientCode & "') and (cur_bal " & sLower & ")"
    ElseIf sLower = "" Then
    sqlquery = "Select Count(Cur_Bal) as BalanceCount from tbl_Distlist_Dep Where (clt_ID = '" & sClientCode & "') and (cur_Bal " & sUpper & ")"
    Else
    sqlquery = "Select Count(Cur_Bal) as BalanceCount from tbl_Distlist_Dep Where (clt_ID = '" & sClientCode & "') and (cur_Bal between " & sLower & " and " & sUpper & ")"
    End If
    End If
    oDBUtil.OpenADORecordSet sqlquery, cnADOSQL, rsADOSQL, 0, adCmdUnknown
    If IsNull(rsADOSQL!balancecount) Then
    CurrentCount = 0#
    Else
    CurrentCount = Format(rsADOSQL!balancecount, "#######")
    End If
    Set rsADOSQL = Nothing

    End Function

  4. #4
    Join Date
    Jul 2006
    Posts
    157
    I am sorry there are total 5 records but three i think are hide under windws upper bar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •