In summary, I have a database (Access) with 4 related tables, as seen in the picture:
In Delphi, I have a TDBGrid
that shows the data from the "resultas" table (using TADOTable
), as seen here:
As you can see, the field for the test id shows numbers (id of the test). What I want is to show the test name instead of that number. Or, can I add a field (in Delphi) that shows the name of the test related to the id (a calculated field, maybe)?
CodePudding user response:
You need Lookup field defined in TADOTable component which is responsible for "Resultas" table. Defining a Lookup Field
Keep in mind that big datasets could result to poor performance. The correct way is to use SELECTs with JOINs in TADOQuery.
CodePudding user response:
TDBGrid
has an OnDrawColumnCell
event. You can custom-drawn any cell to look however you want.
Or, you could simply access the TADOTable
's TField
object for the ID_Test
field, and assign a handler to its OnGetText
event to return the TField.DisplayText
value of the table's Nom_Test
field.