Query Filter: When do I set this at runtime?

I have report (FR4.7) where all the data is coming from the DATA tab of a report (designtime). (using for example TfrxADOQuery)

When opening the report I'd like to set the filter (in code) for the query based on a variable that I pass to the report.

What event would be the right event to do this without ending up with either an empty dataset or an unfiltered dataset?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 1:19PM
    the easiest is to parameterize the query
    in the parameter editor set the type and in the value box select the variable.
    then you can pass a value into the report when loading it
    or use the onactivate event of the report dialog or you can use values from dialog form controls directly in the param editor.
    see the main demo internal datasets internal query for an idea.
  • edited 1:19PM
    gordk wrote: »
    the easiest is to parameterize the query
    in the parameter editor set the type and in the value box select the variable.
    then you can pass a value into the report when loading it
    or use the onactivate event of the report dialog or you can use values from dialog form controls directly in the param editor.
    see the main demo internal datasets internal query for an idea.

    Thanks again for the quick reply [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Using parameter doesn't work. The value is either =0 or >0. I do use parameters quite a lot - wonderful way of working ... (like usual Delphi queries) Passing variables is something I also use - I'd like the report to be as stand-alone as possible so it's not depending on the queries on my Delphi form (thanks for implementing the DATA tab!). I think I'll rewrite the queries to <=0 or <=9999999 ... not pretty, but it should work. I was just curious if the filter of a query on the data tab could be set at runtime (of the report).[/img]
  • gordkgordk St.Catherines On. Canada.
    edited 1:19PM
    Yes it can be, you may also write code to modify it in the begin end. block of the code page

    another method is to set the visibility of the databand in its obp event
    ie:
    masterdata1.visible := (<datasetname."fieldname">) > 0
  • edited 1:19PM
    I didn't think about that ... great suggestion (the begin/end section)!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.