Page 1 of 1

Non-instaniated fields

Posted: Tue Apr 17, 2007 12:40 am
by 9241637
I am having great success getting TeeChart to cooperate, but now have problem I need some help with. I have a dynamic query that can result in a variety of columns using my Delphi 7 app. I don't instantiate the fields in the datamodule, to allow it to accept a variety of columns. If I instantiate the columns I need for the graph, then I leave behind columns that my user may want. If I instantiate all of them, then I lose my advantage of speedy custom searches.

I tried instantiating the ones I needed long enough to get it running, but If I delete them from the query object afterwards the program won't compile.

Any ideas?

Posted: Tue Apr 17, 2007 10:22 am
by narcis
Hi CAC,

Have you also deleted all references to removed ones? Which compilation error do you get?

Thanks in advance.

Posted: Tue Apr 17, 2007 10:49 am
by 9241637
This is the piece of code that gives me a problem:
with dm.qryLResults do
begin
DisableControls;
try
First;
while not(EOF) do
Begin
if dm.qryLResultsSAMPLE_NAME.AsString = SampleName then
if dm.qryLResultsANALYTE.AsString = AnalyteName then
begin
SampleSeries.AddXY(dm.qryLResultsSAMPLE_DATE.AsDateTime, dm.qryLResultsRESULT.AsFloat);
end;

Next;
end;
finally
EnableControls;
end;
if I don't have the fields instantiated, then I get an error like this:
[Error] AnalyticalGraph.pas(192): Undeclared identifier: 'qryLResultsSAMPLE_NAME'
thanks

Posted: Tue Apr 17, 2007 1:17 pm
by narcis
Hi CAC,

Before the if statement you could try checking the number of fields in dm or loop through them to check if fields with given names exists.

Posted: Wed Apr 18, 2007 12:51 pm
by 9241637
I know these columns of data will exist at run time, because the dynamic query in my code is set to run a specific list of key columns. The "catch" is assigning these columns to TeeChart at design time so I can compile the program. It appears that if I instantiate one column, I have to instantiate them all, which defeats the purpose.

One option I have thought of is running two queries, my dynamic query (which will fill grids, and reports), and a second one with the columns needed for the graph already instaniated in a TIBOQuery object.

Posted: Fri Apr 20, 2007 1:40 am
by 9241637
I got some advice from a friend of mine...

When I replaced all the references like

"dm.qryLResultSample_NAME.AsString"

with

"FindField('SAMPLE_NAME').asString"

it worked great!