Subject RE: [IBO] Re: using Tib_Query.Locate in inserting mode
Author Jason Wharton
Just a quick comment, do not use typecasting as you do. This is dangerous
and makes debugging very difficult.

Jason Wharton


> -----Original Message-----
> From: rudi_josic [mailto:rudijosic@...]
> Sent: Wednesday, September 29, 2004 2:21 PM
> To: IBObjects@yahoogroups.com
> Subject: [IBO] Re: using Tib_Query.Locate in inserting mode
>
>
> --- In IBObjects@yahoogroups.com, "Suporte - OnClick" <suporte@o...>
> wrote:
> >
> > Try :
> > if Locate('Cedula',TIB_Edit.Text,[loCaseInsensitive]) then
> >
> >
> >
> > []´s
> >
> >
>
> Thank you "Suporte - OnClick", but is the same result, always returns
> true :(
>
> I found a solution, maybe not the best, but it works
>
> procedure TFormaClientes.EditCedulaExit(Sender: TObject);
> Var
> Q : TIB_Cursor;
> begin
> with TIB_Query(TIB_Edit(sender).DataSource.Dataset) do
> if State = dssInsert then
> try
> Q := TIB_Cursor.Create(self);
> Q.IB_Connection := Dm.DB;
> Q.SQL.Add('Select count(*) from "Clientes" where "Cedula" = '+
> TIB_Edit(sender).Text);
> try
> Q.Open;
> if Q.Fields[0].AsInteger = 1 then
> begin
> ShowMessage(Format(csExiste,['La Cédula','a','a']));
> TIB_Edit(sender).SetFocus;
> TIB_Edit(sender).SelectAll;
> end
> except
> Abort;
> end;
> finally
> FreeAndNil(Q);
> End;
> end;
>
>
> Any comment or improvement will be very apreciated.
>
>
> Best Regards.-
> Rudi Josic.