Board index » delphi » getting the count of records in a filtered query

getting the count of records in a filtered query

I have a listbox that displays the results from a filtered query. how do
i simply get the count again.

labelel.caption := dataset.recordcount;

  doesnt exist.

thanks.

 

Re:getting the count of records in a filtered query


I solved my own problem guys.
the answer is:
query1.recordcount;

but when i use

label.caption := inttostr(query1.recordcount);

i sometimes have a problem where the system appears to run out of memory
or something and doesnt finish compiling. it just kinds of locks up, but
i can reset the compilation. when i comment out the above line of code
it runs fine without it, but when the code is included it locks up and
does not finish compiling.

i am using delphi 5.0 on win 2k. with 396 megs of ram. the code is being
executed in the event handler procedure below as thus:

procedure TForm1.boxedQueryFilterRecord(DataSet: TDataSet;
   var Accept: Boolean);

   var
    fieldval, str:string[4];

begin
  fieldval := dataset['mainnumber'];
  str := rxdblookuplist1.value;
   label1.caption := inttostr(lastquery.recordcount) + ' records';
   //label2.caption := inttostr(boxedquery.recordcount) + ' records';
  accept := ((fieldval <> (str[1] + str[2] + str[3] + str[4])) and
            (fieldval = (str[1] + str[3] + str[2] + str[4])) or
            (fieldval = (str[1] + str[3] + str[4] + str[2])) or
            (fieldval = (str[1] + str[4] + str[2] + str[3])) or
            (fieldval = (str[1] + str[4] + str[3] + str[2])) or
            (fieldval = (str[2] + str[1] + str[3] + str[4])) or
            (fieldval = (str[2] + str[1] + str[4] + str[3])) or
            (fieldval = (str[2] + str[3] + str[1] + str[4])) or
            (fieldval = (str[2] + str[3] + str[4] + str[1])) or
            (fieldval = (str[2] + str[4] + str[1] + str[3])) or
            (fieldval = (str[2] + str[4] + str[3] + str[1])) or
            (fieldval = (str[3] + str[1] + str[2] + str[4])) or
            (fieldval = (str[3] + str[1] + str[4] + str[2])) or
            (fieldval = (str[3] + str[2] + str[1] + str[4])) or
            (fieldval = (str[3] + str[2] + str[4] + str[1])) or
            (fieldval = (str[3] + str[4] + str[1] + str[2])) or
            (fieldval = (str[3] + str[4] + str[2] + str[1])) or
            (fieldval = (str[4] + str[1] + str[2] + str[3])) or
            (fieldval = (str[4] + str[1] + str[3] + str[2])) or
            (fieldval = (str[4] + str[2] + str[1] + str[3])) or
            (fieldval = (str[4] + str[2] + str[3] + str[1])) or
            (fieldval = (str[4] + str[3] + str[1] + str[2])) or
            (fieldval = (str[4] + str[3] + str[2] + str[1])));
end;

As you can see im filtering a query for a certain result so i put the
code in the onfilter event procedure.

any idea as to why the lock up on the line of code to get the recordcount?

thanks

Quote
gaws wrote:
> I have a listbox that displays the results from a filtered query. how do
> i simply get the count again.

> labelel.caption := dataset.recordcount;

>  doesnt exist.

> thanks.

Other Threads