Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing an access database from visual basic

Posted on 1999-01-11
6
Medium Priority
?
171 Views
Last Modified: 2013-11-25
I would like to print a tabel from my access database in visual basic. I really don't no how to do it so please help.
0
Comment
Question by:kgermann
[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
  • 2
6 Comments
 
LVL 3

Expert Comment

by:jjbyers
ID: 1455371
Do you just want a dump to the printer or formatting?

You might want to start with the printer object.

Hope this helps.
0
 
LVL 6

Accepted Solution

by:
clifABB earned 300 total points
ID: 1455372
Here is the easiest way, assuming that you just want to print the total contents of a table:

Add a reference to Access to your project.  Select Project/References menu, select MS Access from the list.

Add the following code
(change Data.mdb to your Access file name, change Table to your table name)
  Dim accApp As New Access.Application
 
  accApp.OpenCurrentDatabase "Data.mdb"
  accApp.DoCmd.OpenTable "Table"
  accApp.DoCmd.PrintOut acPrintAll

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1455373
The other way to do this is as follows:
(You'll need to make sure there is a reference to the data objects)

  Dim dbData  As Database
  Dim rsTable As Recordset
  Dim nCnt1   As Integer
 
  Set dbData = OpenDatabase("c:\mds\data\MDSTables.mdb")
  Set rsTable = dbData.OpenRecordset("Paste Errors")
  For nCnt1 = 0 To rsTable.Fields.Count - 1
    Printer.Print rsTable.Fields(nCnt1).Name; vbTab;
  Next nCnt1
  Printer.Print
  Do Until rsTable.EOF
    For nCnt1 = 0 To rsTable.Fields.Count - 1
      Printer.Print rsTable.Fields(nCnt1); vbTab;
    Next nCnt1
    Printer.Print
    rsTable.MoveNext
  Loop
  Printer.EndDoc

0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:kgermann
ID: 1455374
The code is working fine, but it is only the text from the tabel I am getting. I would like the linies also.

thanks for your help
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1455375
I'm not sure what you mean by "linies".  Can you explain?
0
 

Author Comment

by:kgermann
ID: 1455376
What I mean is that, I would like to see the printing as a tabel they way I do it in access. I hope you understand.

Kasper Germann
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

670 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