[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Printing reports which are stored in Access

Posted on 2003-11-11
6
Medium Priority
?
462 Views
Last Modified: 2010-04-17
What is the code to print reports, which are stored in Access, from VB? Thanks
0
Comment
Question by:matt_fennell
  • 3
  • 3
6 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 9721758
This way:

Const dbPathName = "c:\database.mdb"
Const strPassword = "PASSWORD"
Dim Acc As Object, db As Object

Set Acc = CreateObject("Access.Application")
Set db = Acc.Application.DBEngine.Workspaces(0).OpenDatabase(dbPathName, 0, False, ";pwd=" & strPassword)
Acc.OpenCurrentDatabase dbPathName, False
Set db = Nothing
Acc.DoCmd.OpenReport "ReportName", acPreview
Set Acc = Nothing
0
 

Author Comment

by:matt_fennell
ID: 9722281
This piece of code seems to try and install Access. Would it be simpler if I just used a datacontrol with the recordsource being the report in question?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9722320
If you want to print reports that are into an Access database, you need to have Access already installed onto your PC. The DataControl can only read the data from the Access database.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:matt_fennell
ID: 9722435
Access is already installed. And I have my tables, queries, reports etc saved and linked to my VB program. But for some reason that code you have given me attempts to install Access when it is already installed.

Other than of course "report name" which I changed to the report name in my Access db, what other info needs to be changed from your code? You'll have to forgive my incompetence, I am only a beginner - novice programmer.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9722791
>>And I have my tables, queries, reports etc saved and linked to my VB program

Reports cannot be "linked" to a VB program. A VB program using DAO/ADO/RDO can only use tables and queries.

>> attempts to install Access when it is already installed

Insert your CD and let it go. It may install a feature that wasn't installed initially.
0
 

Author Comment

by:matt_fennell
ID: 9723375
Thank you. Reports are printing.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Simple Linear Regression
Starting up a Project

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question