Board index » delphi » Why Doesn't This Work?

Why Doesn't This Work?

I am trying to validate an entry in a grid component to ensure it is not
null.  Rather than post a message to the user by setting the Required
property to true, I simply want to populate the field with a value of zero
if they delete the entry while in the field.

I am using the following code:

--

Jay B.
jbois...@airmail.net
-------------------------------------------------
Man's mind stretched to a new idea
never goes back to its orginal dimension.
      ==Oliver Wendell Holmes==
-------------------------------------------------

 

Re:Why Doesn't This Work?


I want to validate a field in a grid component so that a minimum value of
zero is assigned to the field if the user deletes the entry.  I am using
the following code:

procedure TfrmMain.qryBealCoverageValidate(Sender: TField);
begin
  If qryBealCoverage.IsNull then
     qryBealCoverage.value := 0;
end;

Delphi recognizes that the field is null if I delete the entry with the
Delete key and performs the line to assign 0 to it, but nothing is assigned
to the field when I inspect the database.  Does anyone know why and/or a
better way to do this?

Thanks,

Jay B.
jbois...@airmail.net
-------------------------------------------------
Man's mind stretched to a new idea
never goes back to its orginal dimension.
      ==Oliver Wendell Holmes==
-------------------------------------------------

Re:Why Doesn't This Work?


Something along the lines of
    If Sender.IsNull then
      Sender.Value := 0;

i.e. change the reference it sent you

Jay Boisseau <jbois...@airmail.net> wrote in article
<01bbf529$3419f040$46044...@jboiss19.iadfw.net>...

Quote
> I want to validate a field in a grid component so that a minimum value of
> zero is assigned to the field if the user deletes the entry.  I am using
> the following code:

> procedure TfrmMain.qryBealCoverageValidate(Sender: TField);
> begin
>   If qryBealCoverage.IsNull then
>      qryBealCoverage.value := 0;
> end;

> Delphi recognizes that the field is null if I delete the entry with the
> Delete key and performs the line to assign 0 to it, but nothing is
assigned
> to the field when I inspect the database.  Does anyone know why and/or a
> better way to do this?

> Thanks,

> Jay B.
> jbois...@airmail.net
> -------------------------------------------------
> Man's mind stretched to a new idea
> never goes back to its orginal dimension.
>       ==Oliver Wendell Holmes==
> -------------------------------------------------

Other Threads