Solved

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

Posted on 1998-08-13
1
122 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
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.
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…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now