Hello Lee,
Sorry not to have been able to help out recently - I've been away.
Looks like your project is really starting to take shape.
With this specific problem you're asking about, I think you need to amend line 4 of your script to read;
form1.edit22.Value := sqlexecute('select IFNULL(max(wksplayed), 0) from matches where id_teams = ' + Form1.ComboBox1.sqlValue) + 1;
As it stands, when no record exists, the wksplayed value is set to 1 and the first record is created.
When 1 record exists, it uses the wksplayed value of the first record (ie 1), adds 1 and creates a second record with a wksplayed value of 2.
When 2 records exist, it still uses the wksplayed value of the first record (ie 1), adds 1 and creates a third record BUT with a wksplayed value of 2.
When 3 records exist, it still uses the wksplayed value of the first record (ie 1), adds 1 and creates a fourth record BUT with a wksplayed value of 2.
And so on and so on - it will NEVER go above a wksplayed value of 2
This is where the 'max' instruction in the script comes into play; using 'max' in the script forces it to read the last record and then add 1. This should then start incrementing the week numbers correctly.
I trust that makes sense and hope it helps,
Derek.