Working in VFP9.0 SP2. This is the first time I'm trying to use a GRID. I thought I had this grid working, but with testing I find it is displaying old data some of the time.
I'm doing a one-to-many form using the grid for the many.
The grid is populated from a cursor ordered_lst useing a SQL statement.
SELECT ordered_lst.qty, part_no, name, base_price FROM ordered_lst
I will run the form the first time, and everything seems fine. I can then quit and restart the form with a new data set. The grid will still be displaying the first data set. I can see that the cursor is correct with a browse command.
I've tried putting a THISFORM.refresh in the page refresh.
How do I get the grid to purge the old data set & refresh itself ?
Don't do a SELECT SQL to 'filter' down to a specific order.
Because each time you execute your query, you are dropping the previous resultant cursor and re-creating a new one. As I said before Grids don't like to have their RecordSource vanish and then reappear.
Instead use an INDEX or a FILTER on the over-all results data table/cursor.
While I personally would recommend using the INDEX approach, here is one method:
NOTE: you would be using Grid's RecordSource = remote_data
SELECT remote_data
SET FILTER TO Order_No = thisform.page1.lookup.disp
GO TOP
ThisForm.Grid1.Refresh
Alternatively in your LOAD Method where you should be building your Remote_Data cursor (READWRITE), you could do something like:
SELECT Remote_Data
INDEX ON Order_No TAG OrdNo FOR Order_No = cOrdNo
where cOrdNo = thisform.page1.lookup.disp
Good Luck