Subject [IBO] Re: using Tib_Query.Locate in inserting mode
Author rudi_josic
--- 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.