Board index » delphi » DBGrid A table and 2 LookupField

DBGrid A table and 2 LookupField

Hello,
I have a DBGrid pointing to 4 Fields in a table and 2 fields
in a lookup table. I know its not possible to edit the 2
lookup fields but I want to. Basically I want wants typed in
the grid to be saved to the LookUp table. Has anyone done
anything similar or does anyone know of a round about way of
doing this.
Basically i am trying to avoid placing a dialog for entering
values for every row in the grid that a user might want to
modify or insert, if not available in the lookup table. The
main table would not be edited.
--
Arnold Johnson
 

Re:DBGrid A table and 2 LookupField


Quote
>Hello,
>I have a DBGrid pointing to 4 Fields in a table and 2 fields
>in a lookup table. I know its not possible to edit the 2
>lookup fields but I want to. Basically I want wants typed in
>the grid to be saved to the LookUp table. Has anyone done
>anything similar or does anyone know of a round about way of
>doing this.
>Basically i am trying to avoid placing a dialog for entering
>values for every row in the grid that a user might want to
>modify or insert, if not available in the lookup table. The
>main table would not be edited.

Whatever  is typed into that field, take that value and first check the table
to see if it exists  and then  do an insert to the lookup table by using a
query object.  Something like this:

First check to see if the value exists(Psuedo Code):

Query1.Sql.Add(' Select * from LookUpTable where Value = Lookup field's value;
Query1.Open;
If Eof = False Then //value doesn't exist
begin
  Query1.Sql.Clear;
  Query1.Sql.Add(' Insert into LookupTable(YourColumn) values(YourLookupField
value);
  Query1.ExecSql;
end;

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Other Threads