Check out MAX()
>I have added your code in my program but the same problem exist. I think my 'set order to inv_no' and other code in my program has conflict. So let me put the question in this way ---
>If I don't use 'Set order' command, how can I find the maximum 'inv_no' in my table?
>
>
>>Hi!
>>
>>I am not sure about the remainder of the code you have that controls these events, but I have found it usually necessary to explicitly set the focus to the first column of a grid after an append. I also usually enter the next available key (in your case inv_no) immediately after appending the record so that I'm not trying to get to an index value of zero.
>>
>>insert into table1 (inv_no) values (max_inv_no + 1)
>>thisform.grid1.refresh
>>thisform.grid1.column1.setfocus
>>
>>HTH
>>Tom.
>>
>>>append blank
>>>thisform.grid1.refresh()
>>>
>>>OK, it is still fine, the user can add data in the 2nd row. But then
>>>when he pressed the enter at the end of 2nd row, it supposted will move to the 3rd row to allow enter new data but the fact is that the cursor moved to the first column of row 2.
>>>If I cancel the 'set order ot inv_no' in the form's INIT, this problem disappears, why? But I need the 'set order' to find the biggest inv_no, I cannot cancel it.
Erik Moore
Clientelligence