Board index » delphi » DBGrid and 'calculated' field values

DBGrid and 'calculated' field values

Greetings!

Is it possible to have a cell of a TDBGrid  return the results of a
lookup from a different table?  My tables are in (mostly) 3rd-Normal
form, so in order to display the course-name in a student's class
schedule, I have to do a lookup from the catalog master file.  I'd
rather not have to use a TStringGrid because in a multi-user setting,
the data could easily be changed from another workstation.  I also don't
want to have to carry the full course name in the student's schedule.

TIA!
--
Stan Campsmith         mailto:mds...@sturec.com
MicroData Systems, Ltd.  http://www.sturec.com

 

Re:DBGrid and 'calculated' field values


You can create a Calculated field and then in your OnCalc event do your
lookup for the other record(through SQL).  It will probably slow down your
app though...

--
Michael Glatz
mgl...@caiso.com

Quote
Stanwood Campsmith wrote in message <36FF562F.E7CD2...@sturec.com>...
>Greetings!

>Is it possible to have a cell of a TDBGrid  return the results of a
>lookup from a different table?  My tables are in (mostly) 3rd-Normal
>form, so in order to display the course-name in a student's class
>schedule, I have to do a lookup from the catalog master file.  I'd
>rather not have to use a TStringGrid because in a multi-user setting,
>the data could easily be changed from another workstation.  I also don't
>want to have to carry the full course name in the student's schedule.

>TIA!
>--
>Stan Campsmith         mailto:mds...@sturec.com
>MicroData Systems, Ltd.  http://www.sturec.com

Re:DBGrid and 'calculated' field values


Quote
>>Is it possible to have a cell of a TDBGrid  return the results of a
>>lookup from a different table?
>>My tables are in (mostly) 3rd-Normal
>>form, so in order to display the course-name in a student's class
>>schedule, I have to do a lookup from the catalog master file.

You can add a lookup field to the dataset.

Double click on the dataset (your TTable or TQuery object) to bring up the
fields editor...
Rightclick and select "New Field"
Enter the name of your field ie:  lkpClassName
Enter the type & size of the field.

Select "Lookup" as the field type.
Fill in the values in the Lookup Definition panel...

The Dataset will be a TTable or Query which points at the Catalog Master
file...

=Bill=

Re:DBGrid and 'calculated' field values


Thanks to all who responded!  With your advice I was able to solve several
challenges at once!

Thanks again!
--
Stan Campsmith         mailto:mds...@sturec.com
MicroData Systems, Ltd.  http://www.sturec.com

Other Threads