I use the TField.origin property to dynamically build a where clause for SQL queries.
So if I have a query such as;
select
p.firstname,
p.lastname,
g.description
from
people p
inner join groups g
I can set the origin of the firstname field to;
FirstNameField.origin = 'p.firstname';
Then use this in the where clause of dynamic queries such as;
SQLWhere = 'where ' + FirstNameField.origin + ' = ''' + MyValue + ''' ';
(obviously i have additional code to prevent against SQL injection).
I do this all the time and it works great. However when trying to track down a bug, I noticed I have one dataset that keeps reseting the value of the origin for example back to;
people.firstname
instead of;
p.firstname
I tracked it down to when the dataset is closed and then reopened. However I do this all the time, so I can't understand why one dataset has different behaviour.
My question is how can I prevent the origin value from getting reset?