Wednesday, April 05, 2006

MS Access Conditions - Empty Table No Export

Macro Issue:

Exporting a table as an Excel Spreadsheet only when the table has values to avoid exporting a blank spreadsheet.

You could put the logic in the Make Query for the table but you would likely get and error in the Macro that ultimately exports the data to Excel since the source would not be present.

So here is a Condition and Action statements that evaluates the table and exports to Excel only when you have values in a particular in the table.

Condition
DCount("[FieldName]","Table Name")<>0
-- It counts the rows in a table to compares to the value of 0.

Action
TransferSpreadsheet

Simple, huh?


No comments: