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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dbgrid to qreport help

Status
Not open for further replies.

ciruscontrols

Technical User
Jul 23, 2009
5
US
Ok I am a beginner and need some help with my first database. Here is what i am doing. I am connecting to and excel sheet. I have a dataset1 extracting the data from an excel file. I am able to transfer the Data to Qreport by first transferring it to another dbgrid and then previewing it (sample for the transfer).

if DataAppF.cDataSet1.State in [dsBrowse] then
begin
Form4.QuickRep1.Preview;
end;

But I need help on how to affix a button on another tab on the form to search for a specific part that is on the DBgrid (this is of course after I have connected to the excel file) I need it to be able to transfer the data to the Qreport .

Here is a brief example.

radiobutton goes and finds a part number that is in list "item id" on the DBgrid, after it finds it, it transfers the cells to the right i.e. component description, qty, etc to the Qreport. The only thing is "item id" is used over and over since its the master number with all associate numbers following to the right. IT is ok if it prints over and over on the Qreport I just need each line that matches to print. I am using a QRlabel on the Qreport with a dataset connected to convert.

If someone can give me some Ideas I would really appreciate it or even teamviewer.com. I just found that learning pascal and building a database is kindof hard in a 9 week time line.


Thanks
 
But I need help on how to affix a button on another tab on the form to search for a specific part that is on the DBgrid (this is of course after I have connected to the excel file) I need it to be able to transfer the data to the Qreport.
I think you have a common misconception:

It sounds like you are thinking that you:
[ul]
[li]took the data from excel[/li]
[li]moved the data to DBGrid[/li]
[li]processed data from DBGrid to QReport[/li]
[/ul]In reality it doesn't work like that. DBGrid is NOT a data container. It is just a way of viewing the data that resides in Excel. QReport is exactly the same thing. It's also NOT a data container and is rather a way of viewing the data that resides in Excel.

That said, just as filters can be applied to the data to create custom displays in DBGrid, the same things can be done in QReport. Use the QRBand.BeforePrint events to filter the data.

Also, to define a range of record to include in the report
Code:
  if DataAppF.cDataSet1.State in [dsBrowse] then
  begin
    DataAppF.cDataSet1.SetRange([FirstRec],[LastRec]);
    Form4.QuickRep1.Preview;
    DataAppF.cDataSet1.CancelRange;
  end;
With an understanding of where the data is, you should have no problem generating custom reports.



Roo
Delphi Rules!
 
ok-I do have it incorrect sounds like.

With the above code when I upload to see it in the first grid, I query it all and sent it it all to another dbgrid and the data is live to modify/delete can I use that code to set a radio-button to read/copy specific cells and send to the Qreport?

Or?

Thanks...
 
Sure. That's how I do it. More specificly, I have a form originally generated with Delphi 'Form Wizard'. (delphi menu > database > Form Wizard). I added a button that generates and displays the QReport from the form.

Your install should include some demo apps for Quick Reports. Mine are in \\Delphi7\Demos\Quickrpt\Qr2\qr2demo.dpr and \\Delphi7\Demos\Quickrpt\Qr3\qr3demo.dpr
Play with those demos. Modify them so they load YOUR data. Step through the code to see how it works.

Your data being in Excel is a little unique BUT if you can see it in a DBGrid, then you already know how to access it. Just apply those methods to QReport.

Give it a try. If you get stuck, post your code. We'll help...



Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top