export query to Excel file (1 Viewer)

eugzl

Member
Local time
Today, 06:33
Joined
Oct 26, 2021
Messages
125
Hi All.
How create VBA Function or Procedure to perform following:
  1. Filter table data by current date
  2. Export result to Excel file
  3. Locate created Excel file to certain network folder
If this is possible, how to do it?
Thanks
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:33
Joined
Feb 28, 2001
Messages
27,186
This is best approached using a "divide and conquer" method.

1. Write a query to filter your table data based on the current date, which is returned by function Date$()

2. Export using the DoCmd.TransferSpreadsheet action, which allows you to name the query that will contain your input and will allow you to specify the output file name AND PATH.

For part 2, here is a link to an article that might explain this well enough for you.


As to how you trigger this, there are many options. Two of them would include

A: A macro using a RunCode option, in which you trigger the TransferSpreadsheet to run on a pre-defined query. Then just run the Macro.

B: An event procedure triggered by a Button-Click event on a form. Then load the form and click the command button.
 

Users who are viewing this thread

Top Bottom