Click to See Complete Forum and Search --> : Running a MS Access Report From VB6


Judgey
May 9th, 2001, 05:51 AM
Hi All,

Have any of you any idea how to Print/Preview a Report which has been created in an Access Database From Visual Basic. I am developing an application which needs to generate quite complex timetables which I can do in Access using the SubReports etc, but not with the DataReport / Data Environment within VB so it would be nice to be ale to just Preview and Print the reports I've already done, Help !!!

Iouri
May 9th, 2001, 07:11 AM
Public Sub RunReport(strDatabase As String, strReport As String)
'=============================================================================
'add ref to Acces 8.0 ( or whatever Access you have)
Dim mobjAccess As Object

Set mobjAccess = New Access.Application
' Open the database
mobjAccess.OpenCurrentDatabase strDatabase
' Open the report in preview mode using the DoCmd object
mobjAccess.DoCmd.OpenReport strReport, acPreview
' Maximize the report window
mobjAccess.DoCmd.Maximize
' Show the Access window
mobjAccess.Visible = True
Set mobjAccess = Nothing

End Sub

'to print report use acViewNormal instead of acPreview. and of course you don't need lines to miximize window and make Accesss visible


Iouri Boutchkine
iouri@hotsheet.com

Judgey
May 9th, 2001, 07:18 AM
Cheers Louri for your speedy response, Just one question, will your code work for machines which do not have MS-Access Installed. Its Just not all staff who will be using it have MS-Access Installed ( Our IT Dept is a bit tight on licences ), this is why I was hesitating on going down this route . .

Iouri
May 9th, 2001, 07:30 AM
No it will not. If you don't want to install Access then create your own report and run it from VB.


Rate it if it helped you.

Iouri Boutchkine
iouri@hotsheet.com

Cimperiali
May 9th, 2001, 07:30 AM
It requires ms-access installed.
Name is Iouri, if I am not wrong...
:-)



Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

Cimperiali
May 9th, 2001, 07:31 AM
Truly? How bad I quickly answer the wrong one!
Thanks for sharing, Iouri

Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

Cimperiali
May 9th, 2001, 07:33 AM
I will rate you tomorrow...

Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

Judgey
May 9th, 2001, 07:35 AM
Sorry for the Speeling mistake on your name Iouri, and I will be rating your post, but can I clarify that If I have already created a report in MS-Access 2000, and this Database file is sitting on the server, will your code preview the report on a machine which doesn't have Access Installed. ( Sorry to be Thick ! )

Share2
May 30th, 2001, 04:19 AM
I suggest you try EasyGrid OCX. It's very easy and powerful.
Maybe it will help you.
Download it from http://www.share2.com/easygrid/

Iouri
May 30th, 2001, 07:10 AM
I think that you cannot preview report on th ecomputer that does not have MS Access installed

Iouri Boutchkine
iouri@hotsheet.com