Solved

Printing an access database from visual basic

Posted on 1999-01-11
6
169 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 100 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
Technology Partners: 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: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

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
Visual Studio 2005 text editor 10 56
Export Data to Different .csv Files 27 133
Send outlook email from VBS Script 2 67
which modules are active in VB6 project? 6 57
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

751 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