PDA

Click to See Complete Forum and Search --> : Printing a DBGrid


spud
Aug 21st, 2000, 06:00 PM
Is there anyway of printing a DBGrid with line's and headings and content, at present I am sending the information to a RTB and printing from there not very good as the content gets out of shape etc

Cheers

Spud

Red Thread
Aug 22nd, 2000, 01:36 AM
I don't know how to print a dbgrid directly to the printer, but can't you print it with crystal reports?

spud
Aug 22nd, 2000, 04:04 PM
Red Thread, I'm new at this can you help on the crystal reports ive found it in VB but havent a clue what to do!
Does it let you print off reports in your application that you have made or does it just allow you to print reports within crystel report itself?

Spud

spud
Aug 22nd, 2000, 04:32 PM
Sorry Red, read up on crystal reports just the thing I need sort off, question the reason i was trying to print the dbgrid was because it contained a search result in it is it posible to do this with crystel reports

Cheers

Spud

(going to post this as a new thread)

Red Thread
Aug 22nd, 2000, 04:41 PM
The looks stay the same, but the amound of data you're send to this report, depends from your program.

ex. with a search in your database you come up with 2 records of data. When you hit the print button, you're chrystal reports will print only this 2 records of data. With your next search, you find 9 records. When you hit the print button, you only can print this 9 records.

When i have time :( i'll send you a little example.

I'm self a newbie VB programmer, but i know this works because i've programmed this once.

Greetings !

TIP : Make sure you have ANY printer on your system installed. Otherwise CR will not show you the data to print in runtime. You must have installed a printer.

spud
Aug 22nd, 2000, 04:52 PM
Cheers Red
Im going to log of now and give it a try and I will get back to you thanks for helping out!



Spud

Red Thread
Aug 23rd, 2000, 11:17 AM
Ok, lets start....

1) make your report the way you want... BUT when you save, DON'T select the "Save data with report". Your report may not contain data. Whe are going to do that...

2) How? Well, send your sql string along !
In the code below you see how is it done. In my sql i state that i will have all artikels where the name the same is as the one in my textbox.

report1.ReportFileName = App.Path & "\detailreport.rpt"
report1.SelectionFormula = "{ARTIKELS.AT_NAME} = '" & txt_name.text & "'"
report1.PrintReport


With this you normally have everything you need to know.

Good luck.

spud
Aug 23rd, 2000, 01:21 PM
Sorry to be a pain Red but can you look at this:


CrystalReport1.ReportFileName = App.Path & "\RecruitSG\new.rpt"
CrystalReport1.SelectionFormula = "{LastName} = '" & Text1.Text & "'"
CrystalReport1.PrintReport


Nothing happens, I dont realy understand the SelectionFormula bit of the code could you help?

Report file: new.rpt
Search textbox: text1.text
Colum to search: LastName
Data Control: data1

Thanks again

Red Thread
Aug 23rd, 2000, 03:53 PM
Look fine at first look, but it will be usefull i've you send me you project. So i can look in detail myself.

I see you only use lastname, but you must write the databasetabel also. ex tabel1.lastname

spud
Aug 23rd, 2000, 05:01 PM
Thats what was wrong I didnt put the table name in but its working fine now, I hope one day I can return the help Red as this has helped me out a grate deal.


Once again thanks!

Spud

Red Thread
Aug 23rd, 2000, 05:30 PM
No thx...

pleasure to help.