Link to home
Start Free TrialLog in
Avatar of corpa
corpa

asked on

Adding a Lookup Field to a ADODataset in runtime?

Hi,
I like to add a LookupField to a ADO Dataset at runtime, since there's always a
different query filling the dataset I don't know the fields in design time.
But I do know the one field I want to use to get filled with data from the
lookupfield is always there.
The the LookupField needs to be connected to another dataset for the lookupdata.
What need I do to create this kind of field after the ADODataset opens?

Regards,
Corpa
Avatar of olmy
olmy

Hi

I found it difficult also to add persistent fields at runtime, but after searching I find it quite easy to do.
I don't have Delphi at this computer, but the basic manover is something like this.

1. create persistent fields for every field in a database. Do this just before calling the <query>.open-procedure.
- I did a simple routine that checkes fieldtypes from query's "fielddefs" (or "fields") that can be retrieved before calling open-procedure. It creates TStringField, TIntegerField, TMemoField, etc. depending the actual field type.
- you have to create persistent field for every field you wish to use with your query.
- dataset-property must be also defined
 
2. also create new persistent field for the lookupfield
3. open the database ;)


I'll send you more detailed examples tommorrow when I have Delphi at my reach.

Regards
  Olmy
ASKER CERTIFIED SOLUTION
Avatar of olmy
olmy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of corpa

ASKER

This is exactly what I wanted,
many thanks,

corpa
Olmy thanks so much for the fantastic solution. I'm posting this 5 years later and it's been a great deal of help! :)
I'm very happy that you found what you were looking for. Thank you for your lovely message :D
  Olmy