?
Solved

Printing reports which are stored in Access

Posted on 2003-11-11
6
Medium Priority
?
455 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

765 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