Dear all,
How do I trap a potential key-violation ?
I am using a grid as an entry form and am permitting the user to click the insert button and enter the text for a new record.
I then (obviously) want to check that the user is not trying to enter an account number that already exists.
I tried the beforeaction event of the DBNavigator thus:
begin
case button of
nbPost: checkNumber;
end;
procedure checkNumber;
begin
table1.setkey;
if (table1.findkey etc..
begin
showmessage('Duplicate account numbers not allowed');
dbnavigator1BtnCkick(nbCancel);
end;
end;
*********
Needless to say, when I deliberately enter an account number that exists, I find that the key violation error occurs before it executes any of my code.
So please, how do I trap the Key violation ? I really want to use a grid for my data entry because it allows editing and entry of new data in the same form thus saving me from having to code seperately.
Thanks inadvance for your help and sorry its long winded.
yomyom.
How do I trap a potential key-violation ?
I am using a grid as an entry form and am permitting the user to click the insert button and enter the text for a new record.
I then (obviously) want to check that the user is not trying to enter an account number that already exists.
I tried the beforeaction event of the DBNavigator thus:
begin
case button of
nbPost: checkNumber;
end;
procedure checkNumber;
begin
table1.setkey;
if (table1.findkey etc..
begin
showmessage('Duplicate account numbers not allowed');
dbnavigator1BtnCkick(nbCancel);
end;
end;
*********
Needless to say, when I deliberately enter an account number that exists, I find that the key violation error occurs before it executes any of my code.
So please, how do I trap the Key violation ? I really want to use a grid for my data entry because it allows editing and entry of new data in the same form thus saving me from having to code seperately.
Thanks inadvance for your help and sorry its long winded.
yomyom.