Solved

Printing an access database from visual basic

Posted on 1999-01-11
6
168 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
  • 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question to Pivot table 1 66
Windows ICD FFU Issue 4 87
Error with a code discussed on this page 5 38
Dinamic report to Crosstab query 9 49
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

679 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