[AccessD] Export to excel

Mark Simms marksimms at verizon.net
Wed Nov 9 14:26:48 CST 2011


The huge problem with any export to Excel is data timeliness....i.e. How
"fresh" is the data ?
Any time someone opens up the Excel workbook, the question becomes "when was
this worksheet last updated from Access ?"
An OLEDB Connection to any Access table or query can be generated statically
within Excel or dynamically from Access using Excel automation. This
guarantees data freshness and synchronization.

The kicker is: not all Access Select queries will be addressable from
Excel...i.e. when they contain "non-standard" SQL functions like "IIF".
(This is another unforgiveable Microsoft "oversight" IMHO - there should
have been an exception for Access queries !).
In that case, you must go thru a "workaround" in creating a table on-the-fly
from the query definition....and then perform an insert from the query
result set. Of course the OLEDB connection property is always set to
reference the table, not the query. On top of that, you must run that Insert
query in the Excel query table BeforeQuery event ..this time with Access
automation. Again, that only has to be done if the Select query is complex
and not directly addressable via OLEDB.

IMHO, this approach really beats all of the others....despite the huge
hassle that Microsoft has imposed for complex queries
Every time you open the Excel workbook....boom...the latest data is just
"there". Better yet: it can be refreshed every 30/60/whatever
minutes....even when users are changing the data.





More information about the AccessD mailing list