Solved

Printing reports which are stored in Access

Posted on 2003-11-11
6
450 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 25 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP installation issues 11 85
some keys in my laptop is not working. any suggestion 6 47
BATCH to EXE Converter 2 67
How to delete text box content on subform 1 16
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

740 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