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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data in grid

Status
Not open for further replies.

Salmano

Programmer
Oct 4, 2001
34
0
0
RO
Hi !

In a form I have a grid with data based on sql statement and a button that launches another form. When I click the button, the form launches ok, but when I close it, the data in the grid is lost.
Does anyone know how could I keep the data in the grid ?

Thank you.
Salmano.
 
You may want to try putting both forms in Private Datasession, and also the cursor of the grid is problem out of scope. When you exit the second form, re-run your sql and reset your grid's recordsource.
 
Thank you mgagnon.

I hoped there is a way not to re-run the sql. It's a compex sql, and it takes some seconds to run... but if there isn't another way...

Thank you again,
Salmano.
 
Salmano

You may want to try the PrivateDataSession first. And on Exit of the second form, the last thing you should do is select your cursor, just to reset focus on the grid.


 
I have had this happen on occasion. Strangely enough, in my case it must have been some kind of compiler corruption or something because deleting the forms and re-creating them from scratch fixed the problem.

The issue that you are having is that the cursor that populates that grid is being closed when your second form exits. Check to see if there is any code in your second form that would close this cursor.

Another thing you might want to try all by itself is to set the AutoCloseTables property to .F. in the DataEnvironment of the second form. Just remember that, if you do this, you will need to manually close any tables you use in the form's Unload event.

Ian
 
you could also create the cursor/table in the .prg that calls the form, and close/delete it in that .prg as well
 
This is from MS Knowledge Base # Q131213;
Set the RecordSource of the grid back to itself as shown in the following code:
Thisform.Grid1.RecordSource = Thisform.Grid1.RecordSource.
See the above mentioned KB article if you want further explanation. It almost fits your problem exactly.
Hope this helps.
 
Hi,

When exiting the second form you might copy the cursor to a table. This could be done in the exit button click event just before issuing thisform.release. The table should have the same structure as the cursor and could be reused by issuing the zap command, then populate table with cursor. Next time zap again and then poputate table from cursor, etc. If the table were use as a recordsource for a grid, then it should not be closed. Only zapped.


Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top