Selecting records within a TQuery for QuickReports

Posted on 2003-03-05
Medium Priority
Last Modified: 2013-11-22
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.


Question by:DavidBond
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 27

Accepted Solution

kretzschmar earned 150 total points
ID: 8073480
you can use the onNeedData-event
for skipping not wanted records


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

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

meikl ;-)

Expert Comment

ID: 8073508
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.

LVL 27

Expert Comment

ID: 8073528
yep, beforeprint may also work

Expert Comment

ID: 8073771
I am not competing with meikl, but could not see his posting while writing

Author Comment

ID: 8082232
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.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question