AviationAce
asked on
DoCmd.OutputTo acOutputTable WHERE
The following code works just fine:
DoCmd.OutputTo acOutputTable, "header", acFormatXLS, "C:\my.xls", True
However I want to filter out only selected records before it is Outputted to the XLS file.
Any ideas?
DoCmd.OutputTo acOutputTable, "header", acFormatXLS, "C:\my.xls", True
However I want to filter out only selected records before it is Outputted to the XLS file.
Any ideas?
ASKER
I think my problem still remains. I will need to change the WHERE statement before the query is ran.
In your query just put on the criteria line something like [Enter the company id to export] (with the brackets) and then when the query runs it will pop-up a box to enter your stuff.
Q-23915388.jpg
Q-23915388.jpg
ASKER
I guess I need to explain what I am doing better. On a form there is a list box. The user will select a value and then click a button to export just one record an XLS file. I am good at building an SQL statement. I just don't see a way to use the DoCmd.OutputTo command to make this happen.
In that case in the criteria of the query you would put Forms!MyFormName!MyListBox Name. When the user clicks to export, it will only select that record.
ASKER
I understand that. But can you give me an example of using as SQL SELECT WHERE statement in a DoCmd.OutputTo command?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You rock! Thanks.
Glad to be of assistance. May all your days get brighter and brighter.
DoCmd.OutputTo acOutputQuery, "header_Query", acFormatXLS, "C:\my.xls", True