Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Qreport /preview...trying to get data from a DBgrid, HELP!

Status
Not open for further replies.

Jelloboy

Programmer
Dec 11, 2002
6
CA

hello!
i'm new at programming(junior), just began learning Delhi. How do I get a print out from a DBgrid up and running?!I'm trying to use the QReport tools and preview but having a hard time!...Please help!!!!

jelooboy
 
Hi there

Just a short tutorial.

1)Create a new QuickReport Form, or just add a TQuicRep to an existing Form.

2)Set the DataSet property of the QuickRep to point to the table you would print out.

3)Set the Bands -> HasDetail property to true.

4)Now to add the fields you want to print, place a QRDBText component on the detail band, you would place one of each of these for every field. Set the DataSet and DataField properties.

6)You can preview a report during designtime by right clicking on the QuickRep and clicking the preview option or to preview or print during runtime ,


{Make sure the table you want to print from is open/active}
Table1.Active:=true;

{To Preview}
QuickRep1.Preview;

{To Print}
QuickRep1.Print;

Thats it , you now have a simple report from the table.

For more info checkout this great resources,


Hope this helps.

P.S

There are some report engines that make it very simple to create a report from a DBGrid,

PrintDat - QR 2+3 PowerPack - SMReport Autogenerated -
And some other great report engines, both of these offer freeware versions,

FreeReport/FastReport -
GmPrintSuite(Pro and Lite) -
 
Thanks for the help BTecho!

I will try it and notify you of the results. thanks for taking the time to help!!!really appreciate it!

Jelloboy
 
BTecho,

I tried what you told me, and it all works...except that I keep getting the same result for every QRDBText. Am I doing something wrong?

Jelloboy
 
Hi m8.

I tried what you told me, and it all works...except that I keep getting the same result for every QRDBText. Am I doing something wrong?

No worries, I think you must have set the same DataField for each QRDBText? you should set the DataField to point to the field you want it to print, so each QRDBText should have that property set differently.

 
sorry!

I must not be clear in my question.....I set four QRDBText fileds with four diff dataset in each one.

There are four columns in the table, with a SQL statement 'select * from table1' in the query. That works fine. I want to display all rows from a DBGrid to the TQuickRep.

I only get one resultset(one row).

I hope this is clearer.

Jelloboy
 
Ok, the DataSet property of all the QRDBText components should point to the same TQuery.

So you place four QRDBText components on the band, align them in the manner you wish, see here
6104a.gif


Then set the DataField property,

QRDBText1 DateField = FieldName1
QRDBText2 DateField = FieldName2
QRDBText3 DateField = FieldName3
QRDBText4 DateField = FieldName4

When you Preview you should see the same amount of records/rows as you see in the DBGrid, but the Report maybe split into a few pages if needed. Also make sure to set the correct Page Size, double click the TQuickRep to set those types of settings.
 
BTecho,

thanks for the help!I will try it this morning!

Jelloboy

 
BTecho

thanks sooo much for the help! everythnig worked out!

Jelloboy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top