# Re: 如何列印 ACCESS 的报表档

Posted by 老怪 on October 01, 1998 at 18:14:41:

In Reply to: 如何列印 ACCESS 的报表档 posted by 尧仔 on September 30, 1998 at 20:18:22:

: 在ACCESS中作好的报表档,如何用VB列印

以下是我从 tw.bbs.comp.language 的 Peter 那儿偷 Copy 来的，希望他知道后别骂我。

Private Sub Command1_Click()
Dim dbname As String
Dim rptname As String
Dim preview As Boolean
dbname = "e:\db1.mdb"
rptname = "report1"
preview = True
Call sub_Report(dbname, rptname, preview)
End Sub

Private Sub sub_Report(ByVal dbname As String, ByVal rptname As
String, ByVal preview As Boolean)
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenCurrentDatabase FilePath:=dbname
.Visible = preview
If preview Then
.DoCmd.OpenReport reportname:=rptname, _
View:=Access.acPreview
Else
.DoCmd.OpenReport reportname:=rptname, _
View:=Access.acNormal
End If
End With
DoEvents
Set objAccess = Nothing

Follow Ups:

- 多谢老怪 尧仔 00:34:25 10/02/98 (0)