I want to print the contents of my db grid. can somebody show me how to do this please. the user will click on a command button which in turn should print the contents of dbgrid.
The easiest way is to use the me.printform command to print the whole vb form. Ohterwise, you could create a printable form, white background, and only the grid, and transfer the data into this. This is by far the easiest way I've found, without using much code.
Thanks for your help. i did already try this but it is not practical as I have more data than can fit on a screen.
The data is held in an access table. is it posible to dump the data into a word document. I managed to mailmerge it, however it worked out that each record would have a seperate page. Ideally I would want it one after another.
You can create an Access report in the same database where your table is, setting the recordsource on the fly to match what's in your dbgrid.
Then you can print that report from within your VB app by using code similar to this:
(Be sure to add a reference to the Access Object Library - this example works with 9.0 Access 2000)
This has worked for me, but there may be better ways to do it -sorry just the basics here; no error-checking. On the 'OpenReport' method, you can include a filter or where clause, etc.
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application"
appAccess.OpenCurrentDatabase ("path to your mdb file"
appAccess.DoCmd.OpenReport "your_reportname", acNormal (or acPreview)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.