Outro exemplo:
Set BancoDeDados = OpenDatabase(App.Path & "olão.MDB", False)
Set TBbolão = BancoDeDados.OpenRecordset("select nome,matricula,[1exp],[1tiro1],[1tiro2],[1tiro3],[1tiro4],[1tiro5],[total1],[2exp],[2tiro1],[2tiro2],[2tiro3],[2tiro4],[2tiro5],[total2],[3exp],[3tiro1],[3tiro2],[3tiro3],[3tiro4],[3tiro5],[total3],[4exp],[4tiro1],[4tiro2],[4tiro3],[4tiro4],[4tiro5],[total4],total from bolão where Data= #" & Format(DBCdatacompetição.Text, "mm/dd/yy") & "# order by Total desc, nove desc, oito desc, sete desc, seis desc, cinco desc, quatro desc, tres desc, dois desc, um desc")
If Not TBbolão.EOF Then
With MSFlexGrid1
.Rows = 1
.Cols = 32
.ColWidth(0) = 350
.ColWidth(1) = 2800
.ColWidth(2) = 750
.ColWidth(3) = 350
.ColWidth(4) = 200
.ColWidth(5) = 200
.ColWidth(6) = 200
.ColWidth(7) = 200
.ColWidth(8) = 200
.ColWidth(9) = 450
.ColWidth(10) = 350
.ColWidth(11) = 200
.ColWidth(12) = 200
.ColWidth(13) = 200
.ColWidth(14) = 200
.ColWidth(15) = 200
.ColWidth(16) = 450
.ColWidth(17) = 350
.ColWidth(18) = 200
.ColWidth(19) = 200
.ColWidth(20) = 200
.ColWidth(21) = 200
.ColWidth(22) = 200
.ColWidth(23) = 450
.ColWidth(24) = 350
.ColWidth(25) = 200
.ColWidth(26) = 200
.ColWidth(27) = 200
.ColWidth(28) = 200
.ColWidth(29) = 200
.ColWidth(30) = 450
.ColWidth(31) = 490
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "Nome do Atleta"
.TextMatrix(0, 2) = "Matricula"
.TextMatrix(0, 3) = "Exp"
.TextMatrix(0, 4) = "1"
.TextMatrix(0, 5) = "2"
.TextMatrix(0, 6) = "3"
.TextMatrix(0, 7) = "4"
.TextMatrix(0, 8) = "5"
.TextMatrix(0, 9) = "Total"
.TextMatrix(0, 10) = "Exp"
.TextMatrix(0, 11) = "1"
.TextMatrix(0, 12) = "2"
.TextMatrix(0, 13) = "3"
.TextMatrix(0, 14) = "4"
.TextMatrix(0, 15) = "5"
.TextMatrix(0, 16) = "Total"
.TextMatrix(0, 17) = "Exp"
.TextMatrix(0, 18) = "1"
.TextMatrix(0, 19) = "2"
.TextMatrix(0, 20) = "3"
.TextMatrix(0, 21) = "4"
.TextMatrix(0, 22) = "5"
.TextMatrix(0, 23) = "Total"
.TextMatrix(0, 24) = "Exp"
.TextMatrix(0, 25) = "1"
.TextMatrix(0, 26) = "2"
.TextMatrix(0, 27) = "3"
.TextMatrix(0, 28) = "4"
.TextMatrix(0, 29) = "5"
.TextMatrix(0, 30) = "Total"
.TextMatrix(0, 31) = "Total"
End With
i = 1
Do While Not TBbolão.EOF
With MSFlexGrid1
.Rows = i + 1
.ColAlignment(0) = flexAlignCenterCenter ' alinha coluna
.TextMatrix(i, 0) = i - 0 ' autonumeração colocar zero para poder começar com 1
.ColAlignment(1) = flexAlignLeftCenter
.TextMatrix(i, 1) = TBbolão(0)
.ColAlignment(2) = flexAlignCenterCenter
.TextMatrix(i, 2) = TBbolão(1)
.ColAlignment(3) = flexAlignCenterCenter
.TextMatrix(i, 3) = TBbolão(2)
.ColAlignment(4) = flexAlignCenterCenter
.TextMatrix(i, 4) = TBbolão(3)
.ColAlignment(5) = flexAlignCenterCenter
.TextMatrix(i, 5) = TBbolão(4)
.ColAlignment(6) = flexAlignCenterCenter
.TextMatrix(i, 6) = TBbolão(5)
.ColAlignment(7) = flexAlignCenterCenter
.TextMatrix(i, 7) = TBbolão(6)
.ColAlignment(8) = flexAlignCenterCenter
.TextMatrix(i, 8) = TBbolão(7)
.ColAlignment(9) = flexAlignCenterCenter
.TextMatrix(i, 9) = TBbolão(8)
.ColAlignment(10) = flexAlignCenterCenter
.TextMatrix(i, 10) = TBbolão(9)
.ColAlignment(11) = flexAlignCenterCenter
.TextMatrix(i, 11) = TBbolão(10)
.ColAlignment(12) = flexAlignCenterCenter
.TextMatrix(i, 12) = TBbolão(11)
.ColAlignment(13) = flexAlignCenterCenter
.TextMatrix(i, 13) = TBbolão(12)
.ColAlignment(14) = flexAlignCenterCenter
.TextMatrix(i, 14) = TBbolão(13)
.ColAlignment(15) = flexAlignCenterCenter
.TextMatrix(i, 15) = TBbolão(14)
.ColAlignment(16) = flexAlignCenterCenter
.TextMatrix(i, 16) = TBbolão(15)
.ColAlignment(17) = flexAlignCenterCenter
.TextMatrix(i, 17) = TBbolão(16)
.ColAlignment(18) = flexAlignCenterCenter
.TextMatrix(i, 18) = TBbolão(17)
.ColAlignment(19) = flexAlignCenterCenter
.TextMatrix(i, 19) = TBbolão(18)
.ColAlignment(20) = flexAlignCenterCenter
.TextMatrix(i, 20) = TBbolão(19)
.ColAlignment(21) = flexAlignCenterCenter
.TextMatrix(i, 21) = TBbolão(20)
.ColAlignment(22) = flexAlignCenterCenter
.TextMatrix(i, 22) = TBbolão(21)
.ColAlignment(23) = flexAlignCenterCenter
.TextMatrix(i, 23) = TBbolão(22)
.ColAlignment(24) = flexAlignCenterCenter
.TextMatrix(i, 24) = TBbolão(23)
.ColAlignment(25) = flexAlignCenterCenter
.TextMatrix(i, 25) = TBbolão(24)
.ColAlignment(26) = flexAlignCenterCenter
.TextMatrix(i, 26) = TBbolão(25)
.ColAlignment(27) = flexAlignCenterCenter
.TextMatrix(i, 27) = TBbolão(26)
.ColAlignment(28) = flexAlignCenterCenter
.TextMatrix(i, 28) = TBbolão(27)
.ColAlignment(29) = flexAlignCenterCenter
.TextMatrix(i, 29) = TBbolão(28)
.ColAlignment(30) = flexAlignCenterCenter
.TextMatrix(i, 30) = TBbolão(29)
.ColAlignment(31) = flexAlignCenterCenter
.TextMatrix(i, 31) = TBbolão(30)
'.ColAlignment(32) = flexAlignCenterCenter
'.TextMatrix(i, 32) = TBbolão(31)
End With
i = i + 1
TBbolão.MoveNext
Loop
End If