General discussion

Locked

DoEvents and Form Unload / visual basic

By rakesh2000_2000 ·
One, I've a loop loading 10,000 data in the grid.
second, i used doevents in the loop so that user can navigate grid as he views the records..
third, if user at same time tries to close the form the form is getting closed and it shows the error of commandtext and form is again loaded and grid continues to load data it left it when form was closed.

fourth, third point has screwed me.

Please heeeeeeeeeeeeeeeeelp

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by JackOfAllTech In reply to DoEvents and Form Unload ...

You'll have to put code in the loop to check if the form is still open. There are several possible ways to do this, check the help for form methods and properties.

Ralph

Collapse -

by RRV In reply to DoEvents and Form Unload ...

10000 rows loading will not be that slow for the user to have time to scroll and close the form. You have to follow some methods of programming. Use MSHFLEXGRID to load the data. before loading use grid.redraw = false. and remember to set it to true when finisht. then set grid.datasouce=myrecordset. in case you do not have recordset and have data at run time to load you can still use doevents.
grid.redraw=false
grid.rows=2
do while not EOF
grid.textarray(CurRow*grid.cols+1)=col1value
grid.textarray(CurRow*grid.cols+2)=col2value
if (grid.rows mod 200)=0 then
grid.redraw=true
doevents
grid.redaw=false
endif
movenext
grid.rows=grid.rows+1
loop
grid.redraw=true

In the unload event of the form use the below code
if RcdSet.State = adStateOpen then
RcdSet.close
endif

This method will sure help you.

All the best
RV

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums