
August 30th, 2004, 02:04 PM
|
|
Contributing User
|
|
Join Date: Aug 2004
Posts: 71
Time spent in forums: 2 m 30 sec
Reputation Power: 4
|
|
|
Docmd.Outputto Help
I am trying to output the result of a query to an excel worksheet. But I
want only the filtered data to go to the sheet. Records are filtered based
on the user input on a form. The command I am giving is as follows:
DoCmd.OutputTo acQuery, "Get_country_Info", "MicrosoftExcel(*.xls)", "C:\Documents and Settings\sagarwal\My Documents\Database\test.xls", True, ""
where "Get_Country_Info" is a predefined query.
It gives me the details of all the countries but I only want the countries which the user selects from the list box in the form
Is there a way I can write the query itself in the OutputTo command? I tried to substitute the query itself instead of passing the query object as follows:
DoCmd.OutputTo acQuery, "select country_name from country where country_name in ( " & tempcountry ")", "MicrosoftExcel(*.xls)", "C:\Documents and Settings\sagarwal\My Documents\Database\test.xls", True, ""
where tempcountry is a list of selected countries by the user. But it gives me an error saying
"database engine could not recognize the oblect 'select country_name from country where country = 'USA'' "
Any ideas??? Thanks in advance.
|