Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-03

Master-detail problem

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Koenraad Lelong

Hi,

I made a application using a master-detail construction. I want to have the detail table follow a master-field, and I want to specify another condition for the detail. This seems not to work. I get an error stating the master-table does not contain a field with the name of my manual parameter.
SQL of master :
select worker_number, worker_name
from worker_table

SQL of detail :
select *
from work_table
where worker_number=:worker_number
and work_date between :from_date and :to_date

When I try to open my master-table I get an error : field :from_date not found in table sqlWorker (=the name of the TSQLquery of the master-table).

When I remove the between clause, everyting is OK.

What am I doing wrong ?

TIA

Koenraad Lelong.

Reply by email

Michael Van Canneyt
to Koenraad Lelong
Koenraad Lelong wrote 23 lines
Hi, I made a application using a master-detail construction. I want to have the detail table follow a master-field, and I want to specify another condition for the detail. This seems not to work. I get an error stating the master-table does not contain a field with the name of my manual parameter. SQL of master : select worker_number, worker_name from worker_table SQL of detail : select * from work_table where worker_number=:worker_number and work_date between :from_date and :to_date When I try to open my master-table I get an error : field :from_date not found in table sqlWorker (=the name of the TSQLquery of the master-table). When I remove the between clause, everyting is OK. What am I doing wrong ?

You must set the value of the :from_date and :to_date in code in the BeforeOpen event. If datasource is set, then ALL values of all unbound parameters are set in the Open event. Setting the parameter 'binds' it, and then it's value will no longer be fetched from the datasource.

Michael.

Reply by email

Koenraad Lelong
to Michael Van Canneyt
Michael Van Canneyt wrote 37 lines
On Thu, 29 Mar 2012, Koenraad Lelong wrote: > Hi, > > I made a application using a master-detail construction. > I want to have the detail table follow a master-field, and I want to > specify another condition for the detail. This seems not to work. I > get an error stating the master-table does not contain a field with > the name of my manual parameter. > SQL of master : > select worker_number, worker_name > from worker_table > > SQL of detail : > select * > from work_table > where worker_number=:worker_number > and work_date between :from_date and :to_date > > When I try to open my master-table I get an error : field :from_date > not found in table sqlWorker (=the name of the TSQLquery of the > master-table). > > When I remove the between clause, everyting is OK. > > What am I doing wrong ? You must set the value of the :from_date and :to_date in code in the BeforeOpen event. If datasource is set, then ALL values of all unbound parameters are set in the Open event. Setting the parameter 'binds' it, and then it's value will no longer be fetched from the datasource. Michael.

Hi,

I submitted a bug-report, with a demo program :
http://bugs.freepascal.org/view.php?id=21660

I filled in the parameters before opening the table, but not in the BeforeOpen event.
If I'm still doing something wrong, please explain.

Thanks,

Koenraad Lelong.

Reply by email