Martin2k Forums

Board index Visual Basic Visual Basic Help

dbgrid help

Ask for help on versions of Visual Basic 6.0 or earlier.

dbgrid help

Postby anasshahid8 » Tue Jun 12, 2012 6:07 pm

hi,
i have a ms access linked database displayed in dbgrid
i want to print(hardcopy) the entire database (dbgrid) and NOT THE FORM.. can i get any code and help in this please
anasshahid8
Newcomer
 
Posts: 2
Joined: Tue Jun 12, 2012 6:04 pm

Re: dbgrid help

Postby Keith » Wed Jun 13, 2012 6:56 pm

Welcome to the forum. :vbwelcome:

First of there are many data grids you can use in VB which one are you using?

Dbgrid32.ocx, Msdatgrd.ocx, Msflxgrd.ocx, Grid32.ocx, Mshflxgd.ocx

Actually I've never need to print the data in each cell but I assume you can do it by loop through the cells and print each cell value you would need to set the position on the printer for each cell to print in the correct place, using Printer.CurrentX and Printer.CurrentY.

Printing a DBGrid: Demo App
I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Image
Keith
Administrator
 
Posts: 869
Joined: Tue Oct 13, 2009 12:15 am
Location: Stoke on Trent, England
Medals: 1
6 Star (1)

Re: dbgrid help

Postby anasshahid8 » Wed Jun 13, 2012 7:37 pm

i tried 3 grids...
DBGRID using DAO
mshflex grid and DataGrid using ADO.. but nothing is working
anasshahid8
Newcomer
 
Posts: 2
Joined: Tue Jun 12, 2012 6:04 pm

Re: dbgrid help

Postby CAdeBiasio » Mon Aug 20, 2012 3:05 pm

Maybe (better: surely) I'm late, maybe my reply could come handy for other users having the same problem. In my experience I've found that reporting on paper is a very delicate and hard job to do for a programmer, and even if I developed several applications able to print out nicely formatted reports, I rather go for the "right tool to do the right job", especially when huge amounts of data are implied in the request.

In the specific, which is the BEST product around for printing data grids? Yep, that's MS Excel. Then I'd suggest that you create a "template", that's an Excel worksheet with all the required formatting (headers, cell formatting/colors, rows to print each page, and so on), then whenever you need to print the content of a grid of yours, you "simply" make a copy of that template and inject data in it, issueing the Print method at the end. This of course requires that you have MS Office (at least, MS Excel) installed on your PC (... but who doesn't?), and that you know how to do some OLE-Server integration in your App. Not THAT easy, but manegeable. And the results are *excellent*.

Claudio
CAdeBiasio
Newcomer
 
Posts: 3
Joined: Mon Aug 20, 2012 2:32 pm


Return to Visual Basic Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron