2019年10月13日 星期日

Access VBA - Display Report 報表顯示輸出(十)

Access VBA - Display Report 報表顯示輸出(十):

在 Access 中創建了簡單報表(Report)後,報表是可以直接顯示和打印,但也可以輸出至不同的格式,在報表顯示輸出會利用按鍵方式,開啓報表,VBA 會使用 DoCmd.OpenReport 句子,非常簡單。

用按鍵方式開啓報表
顯示報表
OpenReport VBA 程式代碼:
Option Compare Database
Private Sub btn_Report_Click()
DoCmd.OpenReport "Rpt_Company", acViewPreview
End Sub

OpenReport 句法(Syntax):
  • Expression.OpenReport ( ReportName , View , FilterName , WhereCondition , WindowMode , OpenArgs )
  • Expression 代表 DoCmd 對象的變量。
OpenReport VBA 程式代碼示範:
DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"

OpenReport(Parameters):
Name
名稱
必需/可選
數據類型
描述說明
ReportName
報告名稱
需要
變體
字符串表達式,是當前數據庫中報表的有效名稱。 如果您在庫數據庫中執行包含OpenReport方法的Visual Basic代碼,Microsoft Access將首先在庫數據庫中,然後在當前數據庫中查找具有此名稱的報表。
View
視圖
可選
AcView
一個AcView常數,用於指定將在其中打開報告的視圖。 默認值為acViewNormal
FilterName
過濾器名稱
可選
變體
字符串表達式,是當前數據庫中查詢的有效名稱。
WhereCondition
條件條件
可選
變體
一個字符串表達式,它是有效的SQL WHERE子句,沒有單詞WHERE。自變量的最大長度為32,768個字符(與Macro窗口中的WhereCondition操作自變量的最大長度為256個字符不同)
WindowMode
窗口模式
可選
AcWindowMode
一個AcWindowMode常量,用於指定表單打開的模式。 默認值為acWindowNormal
OpenArgs
OpenArgs
可選
變體
設置OpenArgs屬性。

AcView枚舉(Enumeration):
Name
數值
描述說明
acViewDesign
1
設計圖
acViewLayout
6
佈局視圖
acViewNormal
0
(默認)普通視圖
acViewPivotChart
4
數據透視圖視圖
acViewPivotTable
3
數據透視表視圖
acViewPreview
2
打印預覽
acViewReport
5
報告檢視

AcWindowMode枚舉(Enumeration):
Name
數值
描述說明
acDialog
3
表單或報表的ModalPopUp屬性設置為Yes
acHidden
1
表單或報表被隱藏。
acIcon
2
窗體或報表將在Windows任務欄中最小化打開。
acWindowNormal
0
(默認)表單或報表以其屬性設置的模式打開。

Operation System : Microsoft Windows 7
Version : Microsoft Office Access 2007

參考網址:
※ DoCmd.OpenReport method (Access)

相關網址:
※ Access - 開始使用 Microsoft Office Access 2007(一)
※ Access - 在 Access 2007 中建立表單(二)
※ Access - 在 Access 2007 編程 VBA(三)
※ Access - 在 Access 2007 語系錯誤訊息(四)
※ Access VBA - TextBox Object 文本框對象(一)
※ Access VBA - ListBox Object 列表框對象(二)
※ Access VBA - ComboBox Object 組合框對象(三)
※ Access VBA - CommandButton Object 按鈕命令對象(四)
※ Access VBA - CheckBox Object 復選框對象(五)
※ Access VBA - Create a Table 建立資料表(六)
※ Access VBA - Create a Form 創建窗體(七)
※ Access VBA - Add a Subform to Existing Form 在主表單加入子窗體(八)
※ Access VBA - Create a Simple Report 創建一個簡單報表(九)
※ Access VBA - Display Report 報表顯示輸出(十)
※ Access VBA - Export Tables to Excel File 將資料匯出至 Excel 檔案(十一)
※ Access VBA - Export Tables to Other File Format 將資料匯出至其他文件格式(十二))

2019年 10月 13日 天氣報告
氣溫:27.9@ 19:20
相對濕度:百分之 75%
天氣:大致多雲,有幾陣驟雨

沒有留言:

張貼留言