> Thanks Stefan, the code worked perfectly....thanks alot and God bless you
You are welcome.
> But i have another problem,
> 1. What is the best way to sum numeric values in a grid eg i have a grid called grid1 with six columns: No, name, marks1, marks2, total,and grade.
> I want to sum values of 'marks1' and 'marks2' and store them in 'total' and then grade the total and store the text value like "pass" or "fail" in 'grade' column
>
That kind of calculations can be presented as "calculated columns", for instance in a View or CursorAdapter, or temporary "Select ... Into Cursor ..."
(With a VFP back-end) the ICASE() expression would be in the SQL field list in that case, perhaps surrounded by Cast().
That way you do not need to store the redundant values in tables persistently.
> 2. When am grading the value in the 'total' column i also need to check if columns 'marks1' and 'marks2' have values or are empty and then grade the total based on this. In other words, if the student did not sit for one of the exam, that means either 'marks1' or 'marks2' is empty, then the grade should be "Course not complete". I hope you got it. Thanks.
>
It's also a calculated result like the one above, right? If you'd post your data structure as a
Create Cursor yourTable (marks1 L, marks2 L, total I ...
... statement, and add a few sample-data lines:
Insert Into yourTable Values (...
and describe the desired result, then surely me or someone else will post an SQL example if you like.
(BTW, I'd suggest to start a new thread for a new question to get more attention.)
hth
-Stefan