i'm on vb6. msflexgrid have error

User avatar
sal21
PlatinumLounger
Posts: 4448
Joined: 26 Apr 2010, 17:36

i'm on vb6. msflexgrid have error

Post by sal21 »

from a:

.rows = UBound(STRDBROWS, 2) + 2 (are 31.757 records)

an in msflexgrid have 11 column to fill.

my complete code:

Code: Select all

Private Sub APRI_FLEXGRID1()

    If Not (RS Is Nothing) Then
        If (RS.State And adStateOpen) = adStateOpen Then RS.Close
        Set RS = Nothing
    End If

    ClearFlex Me.MSFlexGrid1

    Set RS = New ADODB.Recordset
    RS.CursorLocation = adUseClient
    RS.Open SQL, CON, adOpenForwardOnly, adLockReadOnly
    'Debug.Print SQL
    'RS.Sort = ("REGIONE, STATO")

    CNT = RS.RecordCount
    C = 0

    Erase STRDBROWS()
    STRDBROWS = RS.GetRows(RS.RecordCount)
    RS.Close
    Set RS = Nothing

    Dim K As Long, LP As Integer, LA As Integer

    R = 1
    MM = 0
    FF = 0
    TOTT = 0

    With Me.MSFlexGrid1

        If CNT <= 32 Then
            .rows = 33
        Else
          [b]  .rows = UBound(STRDBROWS, 2) + 2 <<<<<<< here error in image[/b]
        End If

        '.Visible = False
        .Sort = False
        .Redraw = False

        For K = 0 To UBound(STRDBROWS, 2)

            .TextMatrix(R, C) = STRDBROWS(0, K)
            .TextMatrix(R, C + 1) = STRDBROWS(1, K)
            .TextMatrix(R, C + 2) = STRDBROWS(2, K)
            .TextMatrix(R, C + 3) = STRDBROWS(3, K)
            .TextMatrix(R, C + 4) = STRDBROWS(4, K)
            .TextMatrix(R, C + 5) = Format(STRDBROWS(5, K), "#,##0")
            .TextMatrix(R, C + 6) = Format(STRDBROWS(6, K), "#,##0")
            .TextMatrix(R, C + 7) = Format(STRDBROWS(7, K), "#,##0")
            .TextMatrix(R, C + 8) = STRDBROWS(8, K)
            .TextMatrix(R, C + 9) = Format(STRDBROWS(5, K), "#00000000")
            .TextMatrix(R, C + 10) = Format(STRDBROWS(6, K), "#00000000")
            .TextMatrix(R, C + 11) = Format(STRDBROWS(7, K), "#00000000")
            .TextMatrix(R, C + 12) = Format(STRDBROWS(1, K), "#00000000")

            MM = MM + STRDBROWS(5, K)
            FF = FF + STRDBROWS(6, K)
            TOTT = TOTT + STRDBROWS(7, K)

            R = R + 1

        Next K

        Me.LTOTALE.Caption = Format(TOTT, "#,##0")
        Me.LNMASCHI.Caption = Format(MM, "#,##0")
        Me.LNFEMMINE.Caption = Format(FF, "#,##0")
        Me.LNRC.Caption = Format(K, "#,##0")

        .TopRow = 1
        .Redraw = True

    End With

End Sub
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 79042
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: i'm on vb6. msflexgrid have error

Post by HansV »

What is the value of UBound(STRDBROWS, 2)?
The maximum number of cells (rows * columns) in a MSFlexGrid control is about 350000
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4448
Joined: 26 Apr 2010, 17:36

Re: i'm on vb6. msflexgrid have error

Post by sal21 »

HansV wrote:
11 May 2024, 09:30
What is the value of UBound(STRDBROWS, 2)?

number of records retuned from sql

The maximum number of cells (rows * columns) in a MSFlexGrid control is about 350000

User avatar
HansV
Administrator
Posts: 79042
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: i'm on vb6. msflexgrid have error

Post by HansV »

I know what it means. But how large is the number of records?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4448
Joined: 26 Apr 2010, 17:36

Re: i'm on vb6. msflexgrid have error

Post by sal21 »

HansV wrote:
11 May 2024, 09:48
I know what it means. But how large is the number of records?
46401

in other case, i found from google:

https://stackoverflow.com/questions/125 ... 006-in-vb6

User avatar
HansV
Administrator
Posts: 79042
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: i'm on vb6. msflexgrid have error

Post by HansV »

That link mentions the same limit that I found: 350000 cells.
With 46401 rows and 13 columns, you're trying to populate more than 600000 cells. That is far above the limit.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4448
Joined: 26 Apr 2010, 17:36

Re: i'm on vb6. msflexgrid have error

Post by sal21 »

HansV wrote:
11 May 2024, 10:32
That link mentions the same limit that I found: 350000 cells.
With 46401 rows and 13 columns, you're trying to populate more than 600000 cells. That is far above the limit.
Resolved whit a group by!
Tks in other case, Bro.

User avatar
HansV
Administrator
Posts: 79042
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: i'm on vb6. msflexgrid have error

Post by HansV »

Glad you found a workaround.
Best wishes,
Hans