?
Solved

Printing reports which are stored in Access

Posted on 2003-11-11
6
Medium Priority
?
459 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

649 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