• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 131
  • Last Modified:

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

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
michaeleu
Asked:
michaeleu
1 Solution
 
watyCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now