OpenReport マクロ アクション
適用先: Access 2013、Office 2013
You can use the OpenReport action to open a report in Design view or Print Preview, or to send the report directly to the printer. また、レポートに印刷するレコードを制限することもできます。
設定
"OpenReport/レポートを開く" アクションの引数は次のとおりです。
アクションの引数 |
説明 |
---|---|
レポート名 |
開くレポートの名前を指定します。 [ マクロ ビルダー] ウィンドウの [ アクションの引数] セクションにある [ レポート名] ボックスには、カレント データベース内のビューがすべて表示されます。 これは必須の引数です。 ライブラリ データベースで OpenReport アクションが定義されているマクロを実行すると、この名前のレポートが、最初にライブラリ データベースで検索され、次にカレント データベースで検索されます。 |
View |
レポートを開くときのビューを指定します。 [ ビュー] ボックスで [ 印刷] (レポートをすぐに印刷する場合)、[ デザイン]、または [ 印刷プレビュー] をクリックします。 既定値は [ 印刷] です。 |
Filter Name/フィルター名 |
A filter that restricts the report's records. You can enter the name of either an existing query or a filter that was saved as a query. However, the query must include all the fields in the report you are opening or have its OutputAllFields property set to Yes. |
Where Condition/Where 条件式 |
A valid SQL WHERE clause (without the word WHERE) or expression that Access uses to select records from the report's underlying table or query. [フィルター名] 引数を使用してフィルターを選択すると、この WHERE 句がフィルターの結果に適用されます。 レポートを開き、そのレコードをフォーム上のコントロールの値で指定されたものに制限するには、次の式を使用します。 注: Where Condition 引数の最大長は 255 文字です。 If you need to enter a more complex SQL WHERE clause longer than this, use the OpenReport method of the DoCmd object in a Visual Basic for Applications (VBA) module instead. You can enter SQL WHERE clause statements of up to 32,768 characters in VBA. |
Window Mode/ウィンドウ モード |
レポートを開くときのモードを指定します。 [ ウィンドウ モード] ボックスで、[ 標準]、[ 非表示]、[ アイコン]、または [ ダイアログ] をクリックします。 既定値は [ 標準] です。 注: 一部のウィンドウ モード引数の設定は、タブ付きドキュメントを使用する場合には適用されません。 ウィンドウを重ねて表示するように切り替えるには、次の操作を行います。
|
注釈
" View/ビュー " 引数で [ 印刷] を選択すると、現在のプリンター設定を使用してすぐにレポートが印刷されますが、[ 印刷] ダイアログ ボックスは表示されません。 また、" OpenReport/レポートを開く " アクションを使用すると、レポートを開いて設定した後に、 PrintOut アクションを使用してレポートを印刷することもできます。 たとえば、印刷前に、レポートを修正したり、" PrintOut/印刷 " アクションを使用してプリンター設定を変更することができます。
The filter and WHERE condition you apply become the setting of the report's Filter property.
The OpenReport action is similar to double-clicking the report in the Navigation Pane, or right-clicking the report in the Navigation Pane and selecting a view or the Print command.
ヒント
複数のデータ セットに対して、類似したレポートを印刷するには、フィルターまたは WHERE 句を使用してレポートに印刷するレコードを制限します。 次に、マクロを編集して別のフィルターを適用するか、Where Condition 引数を変更します。
You can drag a report from the Navigation Pane to a macro action row. This automatically creates an OpenReport action that opens the report in Report view.
例
次の例では、 OpenReport アクションを使用して、レポートを開くときにフィルターを適用するパラメーターを渡す方法を示します。 rptChapters レポートには、cboAuthors コンボ ボックスで選択した項目を SelectedAuthor パラメーターに渡すことで、指定した作成者のレコードが表示されます。
サンプル コードの提供元:Microsoft Access 2010 Programmer's Reference。
OpenReport
Report Name rptChapters
View Report
Filter Name
Where Condition
Window Mode Normal
Parameters
SelectedAuthor =[cboAuthor]