Board index » delphi » Restoring a 'Key Violation' exception

Restoring a 'Key Violation' exception

Hi:

If a user creates a new record but enters an existing value for an index
field, how does one clear the TDBEdit value so that the user starts with
clear edit field in which to enter another value?  DBEdit1.Clear seems
only to blank the visible edit and offending value reappears in that box
at DBEdit1.SetFocus.

Thanks, Nigel

 

Re:Restoring a 'Key Violation' exception


Try,

DBEdit1.Field.Clear;

David

Quote
Nigel D Scott wrote in message <3A09897B.6DA3E...@telusplanet.net>...
>Hi:

>If a user creates a new record but enters an existing value for an index
>field, how does one clear the TDBEdit value so that the user starts with
>clear edit field in which to enter another value?  DBEdit1.Clear seems
>only to blank the visible edit and offending value reappears in that box
>at DBEdit1.SetFocus.

>Thanks, Nigel

Re:Restoring a 'Key Violation' exception


When a key-violation occurs, the user has not successfully posted the
record.  When you trap the exception, set focus to the control and set
the underlying database field to a null value with "Clear."  

Quote
>Nigel D Scott wrote:

> Hi:

> If a user creates a new record but enters an existing value for an index
> field, how does one clear the TDBEdit value so that the user starts with
> clear edit field in which to enter another value?  DBEdit1.Clear seems
> only to blank the visible edit and offending value reappears in that box
> at DBEdit1.SetFocus.

------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)
Quote
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep

Re:Restoring a 'Key Violation' exception


Table1.FieldByName('TheKeyField').Clear;

--
Bill

Other Threads