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

Grid Won't Refresh 1

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US

I have a grid that will not refresh and display recalculated fields. I tried refreshing the grid after the form was refreshed but it still won't update. Why?

The grid has a RecordSourceRType = 4 and uses the following statement in the RecordSource: SELECT * FROM cspl_interest ORDER BY start_date DESC INTO CURSOR Cursor1 NOCONSOLE

The dataenvironment for this form has the cspl_interest table in it.


Here's the code in the recalc button:

gc_adhoc_recalc = "OK"
DO FORM frm_adhoc_recalc && used to recalc the query for a pay off date
IF gc_adhoc_recalc = "OK" then
* Do the ReCalc
DO prg_interest_recalc
THISFORM.REFRESH
THISFORM.GRID1.REFRESH
THISFORM.text2.VALUE = gn_judgement_int && Update Accrued Interest
THISFORM.text3.VALUE = gn_judgement_amt + gn_judgement_int &&Total
ELSE
* = "Cancel" (The ReCalc was canceled)
ENDIF


Here's the code in the prg_interest_recalc program:

select cspl_interest
GO BOTT
REPLACE days WITH ((gd_adhoc_new_end_date - Start_date) + 1) && days in period
REPLACE per_diem WITH ;
((interest_rate/100)/((gd_adhoc_new_end_date - Start_Date) + 1) * gn_judgement_amt) && recalc per_diem
REPLACE interest_amt WITH ((((interest_rate/100)/365) * gn_judgement_amt) *days)
SUM interest_amt TO gn_judgement_int
RETURN

The 2nd mouse gets the cheese.
 
Hi!

The problem is not in the recalculations or something like that. The problem is in the SQL Statement. It is a single-use approach. This means that when grid initialized, it runs SQL Select statement once, puts result into some cursor and uses that cursor to display data. Now you can discover that all columns of grid are based on that cursor looking to the column's control source property (you can use this to get the name of cursor that produced by SQL Statement).

In your case to organize refreshing you should assign SQL Statement again to the record source of grid. Grid's refresh method just refreshes grid appearance from the cursor used to display data.

Another approach might be more effective - run query manually to some cursor with predefined name and than use result cursor as grid's record source.

Either way be aware about grid Record Source change tricks to avoid grid reconstruction. Before requery (close/open) of cursor used by grid assign empty string to the grid's record source, requery data and than assign record source again. Note that you also will require to restore clumn control sources after such operation. This applies to both above approaches.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 

Thank you my friend for the detailed explanation. :)
The 2nd mouse gets the cheese.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top