Subject Re: Valide of Fields
Author nelsonvechini
Excuse, I wrote in Portuguese...I imagined that somebody of Brazil
was able to me to answer.

Here it is going in English:

The code of the event onValidateFields is:

begin
IF (AFIELD.FIELDNAME <> ' CODPRODUTO') OR
(ARow.Columns[0] .IsNull) or
(ARow.Columns[0] .AsString = ' 0 ') or
(ibVenda.State = dssBrowse) then
Exit;

q.Close;
q.SQL.Clear;
Q.SQL.ADD (' SELECT CODPRODUTO, VALORVENDA, CODUNIDADE FROM
PRODUTO');
Q.SQL.ADD (' WHERE CODPRODUTO = ' + TRIM(AROW.COLUMNS
[0] .ASSTRING));
q.Open;

if q.RecordCount = 0 then
begin
MessageBox(Application.Handle,
Pchar (' Product not registered.
Verify!! '),
' Consistence of Data', MB_ICONASTERISK +
MB_OK);
end;

IBVENDA.FIELDBYNAME (' QTDE') .VALUE := 1;
IBVENDA.FIELDBYNAME (' VALORUNIT') .VALUE := Q.FIELDS
[1] .VALUE;
IBVENDA.FIELDBYNAME (' CODUNIDADE') .VALUE := Q.FIELDS
[2] .VALUE;

They put he doesn't catch only the field CODPRODUTO, he passes
several times. It seems that catches only the primary key.

In relation to the content of Getting Started Guide, would like to
find this treatment type ...I suppose that is basic.

Hugs


--- In IBObjects@yahoogroups.com, "nelsonvechini"
<nelsonvechini@t...> wrote:
>
> O código do evento onValidateFields é:
>
> begin
> if (AField.FieldName <> 'CODPRODUTO') or
> (ARow.Columns[0].IsNull) or
> (ARow.Columns[0].AsString = '0') or
> (ibVenda.State = dssBrowse) then
> Exit;
>
> q.Close;
> q.SQL.Clear;
> q.SQL.Add('select CODPRODUTO, VALORVENDA, CODUNIDADE from
> PRODUTO');
> q.SQL.Add('where CODPRODUTO = ' + Trim(ARow.Columns
> [0].AsString));
> q.Open;
>
> if q.RecordCount = 0 then
> begin
> MessageBox(Application.Handle,
> Pchar('Produto não cadastrado.
> Verifique !!'),
> 'Consistência de Dados', MB_ICONASTERISK +
> MB_OK);
> end;
>
> ibVenda.FieldByName('QTDE').Value := 1;
> ibVenda.FieldByName('VALORUNIT').Value := q.Fields[1].Value;
> ibVenda.FieldByName('CODUNIDADE').Value := q.Fields[2].Value;
>
> Porem ele não pega somente o campo CODPRODUTO, ele passa várias
> vezes. Parece que pega somente a chave primária.
>
> Em relação ao conteúdo do Getting Started Guide, gostaria de
> encontrar este tipo de tratamento...que eu suponho que seja básico.
>
> Abraços
>
> --- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> > At 10:59 AM 15/10/2004 -0300, you wrote:
> >
> > >Hello
> > >
> > >How do I do to validate an entrance of data in a TIB_Grid that
is
> linked to
> > >a TIB_Query?
> > >E.g. have a column that is informed the code of the product and
I
> want to
> > >validate the code it is correct.
> > >I tried to use the event onValidadeField of TIB_Query but I
> didn't have
> > >success.
> >
> > Show the code.
> >
> > >I already researched in Getting Started Guide but I didn't find
> anything. I
> > >thought he was more complete...is there some more advanced
> reference?
> >
> > What do you need? Writing event handlers? Handling
exceptions?
> Use the
> > Delphi Help.
> >
> > Helen