Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing an Access report in VB6

Status
Not open for further replies.

Mondrigore

Programmer
Dec 15, 2001
2
US
I have used code similar to the following:

Public Const acPreview = 2
Public Const acNormal = 0

Public Sub RunReport(Subject As String, Optional Preview As Variant)
Dim Access As Object
If IsMissing(Preview) Then Preview = False
Set Access = CreateObject("Access.Application")
With Access
.OpenCurrentDatabase filepath:=DB_NAME
If Preview Then 'preview report on screen
.Visible = True
.DoCmd.OpenReport Subject, acPreview
Else 'print report to printer
.DoCmd.OpenReport Subject, acNormal
DoEvents 'allow report to be sent to printer
End If
End With
Set Access = Nothing
End Sub

This allows me to print a report created in Access from my vb program and it works fine on a PC with Access installed on it. The problem I have is that if I install my program on a PC WITHOUT MS Access I get run-time error 429. What do I need to do to allow non-Access PC's the ability to print these reports? I have Office 97 Developer.
 
Have you tried installing the Access runtime version? It's part of Office Developer (at least the 2000 version, don't know about the 97 version) and you can include it in your application setup program when you use the Package & Deployment Wizard.
 
Thanks andyclt, do you package the database in developer and include that, or can you just create a vanilla run-time without a database?
 
You can't open an Access Report in Preview even when the Access exist on the machine. When You use the automation You will be able only to print an Access report.
I've try!
I've export the report into a rtf file and i've open it in a RichTextBox. After that I print it (I've use Access to print it because when You export the file in rtf You loose some formating - ex. lines).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top