I have 2 DBF tables, "TABLE A" and "TABLE B".
I have a data Entry grid that inserts records into "Table A" and updates existing records in "TABLE B" using the AfterInsertRecord handler.
"TABLE A" holds records of different football games by adding results after each game, while "TABLE B" is the league table showing all teams and total goals scored in the league. The data entry grid is submitted into "TABLE A" after each game (e.g. Nigeria - 3, Argentina 2).
The AfterInsertRecord handler is supposed to update "TABLE B" by summing up the new scores with the existing total league goals scored to get a new figure for total league goals .
I used the following code in the AfterInsertRecord handler but it doesn't work. Instead of updating "TABLE B" by summing up the old and new figures, it just adds the new figure behind of the old figure. For example, if Nigeria has existing 5 league goals before the above example result is entered, it returns 53 instead of 8. I need it to sum up 3 and 5 to get 8, not write 3 behind the 5 to get 53. Here is my code.....
dim tbl as p
dim indx as p
tbl = table.open("[PathAlias.ADB_Path]\football_table")
query.filter = "Team = '"+e.datasubmitted.Home_Team+"'"
query.order = "Team"
query.options = "t"
indx = tbl.query_create( )
count = indx.records_get()
tbl.fetch_first()
WHILE .NOT. tbl.fetch_eof()
dim Goals as n
tbl.change_begin(.t.)
Goals=tbl.Goals
Goals = tbl.Goals + e.datasubmitted.Home_score
tbl.Goals= Goals
tbl.change_end(.t.)
tbl.fetch_next()
END WHILE
I know my problem is in this line............
"Goals = tbl.Goals + e.datasubmitted.Home_score"
Please help me with the correction for this code so that is will sum up.
Thank you.
I have a data Entry grid that inserts records into "Table A" and updates existing records in "TABLE B" using the AfterInsertRecord handler.
"TABLE A" holds records of different football games by adding results after each game, while "TABLE B" is the league table showing all teams and total goals scored in the league. The data entry grid is submitted into "TABLE A" after each game (e.g. Nigeria - 3, Argentina 2).
The AfterInsertRecord handler is supposed to update "TABLE B" by summing up the new scores with the existing total league goals scored to get a new figure for total league goals .
I used the following code in the AfterInsertRecord handler but it doesn't work. Instead of updating "TABLE B" by summing up the old and new figures, it just adds the new figure behind of the old figure. For example, if Nigeria has existing 5 league goals before the above example result is entered, it returns 53 instead of 8. I need it to sum up 3 and 5 to get 8, not write 3 behind the 5 to get 53. Here is my code.....
dim tbl as p
dim indx as p
tbl = table.open("[PathAlias.ADB_Path]\football_table")
query.filter = "Team = '"+e.datasubmitted.Home_Team+"'"
query.order = "Team"
query.options = "t"
indx = tbl.query_create( )
count = indx.records_get()
tbl.fetch_first()
WHILE .NOT. tbl.fetch_eof()
dim Goals as n
tbl.change_begin(.t.)
Goals=tbl.Goals
Goals = tbl.Goals + e.datasubmitted.Home_score
tbl.Goals= Goals
tbl.change_end(.t.)
tbl.fetch_next()
END WHILE
I know my problem is in this line............
"Goals = tbl.Goals + e.datasubmitted.Home_score"
Please help me with the correction for this code so that is will sum up.
Thank you.
Comment