Board index » delphi » Filtered property but no Filter property?

Filtered property but no Filter property?

Hi all,

I'm converting an app over to the IB components from the regular BDE driven data
components.

D5, SP1, IB 5.6 for now until the program is converted.

I have a form with a db grid linked to a TQuery that shows PO data. I use a
filter on the TQuery to limit what the user sees based on their selection so I
do not have to make a call to the database every time they change their view.
(open, closed, etc.) Limiting the data access is a big deal since users
frequently change their view and I don't want them to be constantly hitting the
DB, especially on a larger network.

The TIBQuery has a Filtered property but no published Filter property. I can
still set the Filter at run time but nothing happens, my view is not 'filtered'.

Will the Filter be exposed at some time or do I need to take a different path to
do this? Or am I just a moron and doing something wrong?

Thanks for any help.
Todd Asher
ash...@yadasystems.com

code example:

procedure TFormPO.RadioGroup1Click(Sender: TObject);
begin
qryPOList.Filtered := False;//view all
Case RadioGroup1.ItemIndex of//only set filter to restrict view if one of these
items are checked
   1 : begin//view open
       qryPOList.Filter := 'STATUS = ''O'' or STATUS = ''P''';
       qryPOList.Filtered := True;
       end;
   2 : begin//view closed
       qryPOList.Filtered := False;
       qryPOList.Filter := 'STATUS = ''C''';
       qryPOList.Filtered := True;
       end;
   3 : begin//view voided
       qryPOList.Filtered := False;
       qryPOList.Filter := 'STATUS = ''V''';
       qryPOList.Filtered := True;
       end;
   end;//case
end;

 

Re:Filtered property but no Filter property?


Quote
RayZor{*word*128}wrote:

> Hi all,

> I'm converting an app over to the IB components from the regular BDE driven data
> components.

> D5, SP1, IB 5.6 for now until the program is converted.

> I have a form with a db grid linked to a TQuery that shows PO data. I use a
> filter on the TQuery to limit what the user sees based on their selection so I
> do not have to make a call to the database every time they change their view.
> (open, closed, etc.) Limiting the data access is a big deal since users
> frequently change their view and I don't want them to be constantly hitting the
> DB, especially on a larger network.

> The TIBQuery has a Filtered property but no published Filter property. I can
> still set the Filter at run time but nothing happens, my view is not 'filtered'.

Filtered works in conjunction with a OnFilterRecord event.  Filter is not
supported at this time.

- Show quoted text -

Quote
> Will the Filter be exposed at some time or do I need to take a different path to
> do this? Or am I just a moron and doing something wrong?

> Thanks for any help.
> Todd Asher
> ash...@yadasystems.com

> code example:

> procedure TFormPO.RadioGroup1Click(Sender: TObject);
> begin
> qryPOList.Filtered := False;//view all
> Case RadioGroup1.ItemIndex of//only set filter to restrict view if one of these
> items are checked
>    1 : begin//view open
>        qryPOList.Filter := 'STATUS = ''O'' or STATUS = ''P''';
>        qryPOList.Filtered := True;
>        end;
>    2 : begin//view closed
>        qryPOList.Filtered := False;
>        qryPOList.Filter := 'STATUS = ''C''';
>        qryPOList.Filtered := True;
>        end;
>    3 : begin//view voided
>        qryPOList.Filtered := False;
>        qryPOList.Filter := 'STATUS = ''V''';
>        qryPOList.Filtered := True;
>        end;
>    end;//case
> end;

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
The correct way to punctuate a sentence that starts: "Of course it is
none of my business but ~" is to place a period after the word "but".
Don't use excessive force in supplying such a moron with a period.
Cutting his throat is only a momentary pleasure and is bound to get
you talked about.   (RAH)

Re:Filtered property but no Filter property?


Thanks Jeff, I got it working again.

btw- is your new quote from Robert Heinlein? Sorta sounds like something he would have
written.

Quote
"Jeff Overcash (TeamB)" wrote:

> Filtered works in conjunction with a OnFilterRecord event.  Filter is not
> supported at this time.

OK, for all you lazy folks like me who did not use OnFilterRecord here is how to do
it.

2 things need to happen. Something must trigger Filtered off and on. Some criteria
must be set for filtering.
Here a TRadioGroup is used to trigger filter off and on. Item zero is all items = no
filtering.

procedure TFormPO.RadioGroup1Click(Sender: TObject);
begin
qryPOList.Filtered := False;//set to false each time to insure new filtering will
happen if needed
if RadioGroup1.ItemIndex > 0 then
   qryPOList.Filtered := True;//view a filtered set based on item index - sets new
filtering based in index
end;

procedure TFormPO.qryPOListFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
Case RadioGroup1.ItemIndex of
   1 : Accept := (DataSet['STATUS'] = 'O');//view open
   2 : Accept := (DataSet['STATUS'] = 'C');//view closed
   3 : Accept := (DataSet['STATUS'] = 'V');//view voided
   end;//case
end;

Re:Filtered property but no Filter property?


Quote
RayZor{*word*128}wrote:

> Thanks Jeff, I got it working again.

> btw- is your new quote from Robert Heinlein? Sorta sounds like something he would have
> written.

Yes, (RAH) will always stand for Robert Anson Heinlein for me :).

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
The correct way to punctuate a sentence that starts: "Of course it is
none of my business but ~" is to place a period after the word "but".
Don't use excessive force in supplying such a moron with a period.
Cutting his throat is only a momentary pleasure and is bound to get
you talked about.   (RAH)

Other Threads