Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Selecting records within a TQuery for QuickReports

Quick plea for help with using QuickReport3 with Delphi 7.
I'm using a TQuery dataset to drive a QuickReport form for a large(ish) set of user data. As well as the normal ordering, I want to be able to allow the user to print specific records from the resulting dataset.
Is there a way of setting the TQuickRep component to ignore/skip specific records in the preview / print ?
Or, do I need to go down the quick/nasty route of creating a temp dataset and copy over the relevant records ?

I'd grateful for any help or suggestions.

Thanks,

David
0
DavidBond
Asked:
DavidBond
  • 2
  • 2
1 Solution
 
kretzschmarCommented:
you can use the onNeedData-event
for skipping not wanted records

like

while (dataset.FieldByName('WhatEverFieldName').AsWhatType <> YourCondition) and not (dataset.eof) do
  dataset.next;

another way would be to append a whereclause
to the sql-statement at runtime and restart the report

meikl ;-)
0
 
classmateCommented:
if you cannot use SQL statements to filter out the not wanted records, you may try to use the PRINTBAND var-parameter in the BeforePrint event handler of your band. Printband must be set to false if you do not want the current record to be printed. At this point, the query's cursor will be positioned at the record you want to test.

classmate.
0
 
kretzschmarCommented:
yep, beforeprint may also work
0
 
classmateCommented:
;-)
I am not competing with meikl, but could not see his posting while writing
;-)
0
 
DavidBondAuthor Commented:
Finally back around to trying the OnNeedData Event - worked nicely (setting the MoreData flag as appropriate for the conditions). I hadn't tried using this before as I hadn't found any documentation on it.
Thanks everyone for the help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now