Solved

How to print the content of a MS Access file using VB?

Posted on 1998-08-13
1
125 Views
Last Modified: 2010-04-30
I have to write a programme which update the table in a MS Access file...after that, I have to print out the content (ie. the table) using the printer...How could I do that?
that's urgent...
0
Comment
Question by:michaeleu
1 Comment
 
LVL 14

Accepted Solution

by:
waty earned 20 total points
ID: 1468693
Here a solution :

dim rs     as RecordSet
dim nI     as integer
dim sData  as string

gsSeparator = " | "

set rs = DB.OpenRecordSet("Select * from Table")

Do while rs.EOF=false
   sData = ""
   For nI = 0 To rs.Fields.Count - 1
      sData = sData & CStr(record.Fields(nI)) & gsSeparator
   Next

   if Len(sData) > 0 then
      sData = Left(sData, len(sData) - len(gsSeparator))
   end if

   printer.print sData

   rs.MoveNExt
loop

Printer.EndDocument


Otherwise, you could use my Print Preview. You can find it on my web site. It can generate reports based on a database.

http://www.geocities.com/ResearchTriangle/6311/
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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 lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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