Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating MSHFLEXGRID

Status
Not open for further replies.

TondoBoy

Programmer
Mar 22, 2001
31
US
What am I doing wrong? I ran the same SQL on my Access database and I showed 194 records but when I ran this code in the VB program to populate my MSHFlexGrid only the last 20 or so are showing on the grid. Running the debug, I can see that it is picking up every record up to number 22 and then it abruptly exits the debugger. When the grid flashes back on the screen, the every record except the last 20 or so is showing.

x% = OpenGLedger(rsAny)
rsAny.Open ParmSQL, GLedgerconn, adOpenDynamic, adLockOptimistic
rsAny.MoveFirst
'hfgbud.Row = hfgbud.Rows - 1
AddGridRow
Do While Not rsAny.EOF
For I = 4 To hfgbud.Rows - 1 'Starts at line 4
strData(0) = rsAny!FullAccount
strData(1) = rsAny!Description
strData(2) = rsAny!Total
strData(3) = rsAny!Amount01
strData(4) = rsAny!Amount02
strData(5) = rsAny!Amount03
strData(6) = rsAny!Amount04
strData(7) = rsAny!Amount05
strData(8) = rsAny!Amount06
strData(9) = rsAny!Amount07
strData(10) = rsAny!Amount08
strData(11) = rsAny!Amount09
strData(12) = rsAny!Amount10
strData(13) = rsAny!Amount11
strData(14) = rsAny!Amount12

For J = 0 To hfgbud.Cols - 1
hfgbud.TextMatrix(I, J) = strData(J)
Next
rsAny.MoveNext
If rsAny.EOF Then
Exit Sub
End If
Next
AddGridRow
Loop

rsAny.Close
errhand:
MsgBox "Error: " & Err.Description

 
I found the solution to my problem. Outside of the the DO Loop, assign I = row number and inside the loop replace the syntax " For I = 4 To hfgbud.Rows - 1 " with I = I +1. Remove the outside "Next".

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top