利用 Access 強大的報表設計器設計版面,VB 僅負責觸發列印/預覽,避免 Crystal Reports 學習曲線與授權成本。
novelty.mdb) 與報表 (如 rptEmployees)。' 參考: Microsoft Access 8.0 Object Library
Dim MSAccess As Access.Application
Private Sub Command1_Click()
Set MSAccess = New Access.Application
MSAccess.OpenCurrentDatabase App.Path & "\novelty.mdb"
MSAccess.DoCmd.OpenReport "rptEmployees", acViewNormal ' 直接列印
' acViewPreview 可改為預覽
MSAccess.CloseCurrentDatabase
Set MSAccess = Nothing
End Sub
OpenReport 檢視模式常數acViewNormal (0) - 直接列印acViewPreview (1) - 預覽acViewDesign (2) - 設計檢視