5 replies
by tarran
Probably the simplest way is using a Mocrosoft Word object.
I am not sure of the actual object calls, but if you can record a Macro as you carry out the following steps & use it as the source of your VB code:
Create new word document.
Selectfrom tools menu mail merge.
Configure the maind document for the labels you wich to print.
Slect your access database as your data source.
Design & print your labels.
Stop recording the macro.
Go into visual basic editor from word and cut &paste from the macro module the code you just generated into your program, editing it to automate the behavior.
I advise spending time doing this since formatting Access reports is time consuming and thankless.
by desmondm
by miss kitty
This is code that I have seen at several VB sites. This is a question that is asked alot since it is easier to write in Access.
Public Sub PrintAccessReport(dbname As String, rptname As String, _
preview As Boolean)
Dim objAccess As Object
On Error GoTo PrintAccessReport_ErrHandler
Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenCurrentDatabase filepath:=dbname
If preview Then
'Preview report on screen.
.Visible = True
.DoCmd.OpenReport reportname:=rptname,
View:=Access.acPreview
Else
'Print report to printer.
.DoCmd.OpenReport reportname:=rptname,
View:=Access.acNormal
DoEvents
'Allow report to be sent to printer.
End If
End With
Set objAccess = Nothing
Exit Sub
PrintAccessReport_ErrHandler:
MsgBox Error$(), , "Print Access Report"
End Sub
Cathy
covcat@riverstonegrp.com
by desmondm
by desmondm
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending