Since under Access 2007 reports can no longer be exported to Excel, I'm
attempting to open the query that the report is based on so that I can
export the query to Excel. I'm wondering, though, about the best way to open
the query since I need to apply a filter. It was easy enough to do in the
OpenReport call by using the WhereCondition parameter, but OpenQuery has no
such parameter. What is the best way to filter a query through code?
Thanks,
Carl Rapson
|
|
0
|
|
|
|
Reply
|
Carl
|
5/31/2007 8:10:59 PM |
|
A fairly simple workaround is to save the query you want to use for
exporting. Then write its SQL property before you do the export.
The idea is to switch the query to SQL View, and spit it into 2 strings so
you can patch the WHERE clause between them. This kind of thing:
Dim strWhere As String
Const strcStub = "SELECT * FROM Table1 WHERE ("
Const strcTail = ") ORDER BY Table1.ID;"
strWhere = "SomeField = 99"
Currentdb.QueryDefs("Query1").SQL = strcStub & strWhere & strcTail
DoCmd.TransferSpreadsheet ...
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Carl Rapson" <mr.mxyzptlk@newsgroups.nospam> wrote in message
news:%23w8Ma$7oHHA.3368@TK2MSFTNGP02.phx.gbl...
> Since under Access 2007 reports can no longer be exported to Excel, I'm
> attempting to open the query that the report is based on so that I can
> export the query to Excel. I'm wondering, though, about the best way to
> open the query since I need to apply a filter. It was easy enough to do in
> the OpenReport call by using the WhereCondition parameter, but OpenQuery
> has no such parameter. What is the best way to filter a query through
> code?
>
> Thanks,
>
> Carl Rapson
|
|
0
|
|
|
|
Reply
|
Allen
|
6/1/2007 2:54:34 AM
|
|
Thanks Allen, I'll take a look at that. I guess I'm going to have to get
used to working more with Queries in Access 2007. Reports seem to have been
"dumbed down" in some ways.
Carl Rapson
"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
news:emtmxg$oHHA.588@TK2MSFTNGP06.phx.gbl...
>A fairly simple workaround is to save the query you want to use for
>exporting. Then write its SQL property before you do the export.
>
> The idea is to switch the query to SQL View, and spit it into 2 strings so
> you can patch the WHERE clause between them. This kind of thing:
>
> Dim strWhere As String
> Const strcStub = "SELECT * FROM Table1 WHERE ("
> Const strcTail = ") ORDER BY Table1.ID;"
>
> strWhere = "SomeField = 99"
> Currentdb.QueryDefs("Query1").SQL = strcStub & strWhere & strcTail
> DoCmd.TransferSpreadsheet ...
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Carl Rapson" <mr.mxyzptlk@newsgroups.nospam> wrote in message
> news:%23w8Ma$7oHHA.3368@TK2MSFTNGP02.phx.gbl...
>> Since under Access 2007 reports can no longer be exported to Excel, I'm
>> attempting to open the query that the report is based on so that I can
>> export the query to Excel. I'm wondering, though, about the best way to
>> open the query since I need to apply a filter. It was easy enough to do
>> in the OpenReport call by using the WhereCondition parameter, but
>> OpenQuery has no such parameter. What is the best way to filter a query
>> through code?
>>
>> Thanks,
>>
>> Carl Rapson
>
|
|
0
|
|
|
|
Reply
|
Carl
|
6/1/2007 3:03:53 PM
|
|
|
2 Replies
695 Views
(page loaded in 0.083 seconds)
Similiar Articles: Opening a query with a filter in Access 2007 - microsoft.public ...Since under Access 2007 reports can no longer be exported to Excel, I'm attempting to open the query that the report is based on so that I can expor... 2007 Forms - Quick Filters not working - microsoft.public.access ...Opening a query with a filter in Access 2007 - microsoft.public ... 2007 Forms - Quick Filters not working - microsoft.public.access ..... new split form on the same query ... Access 2007, Query's prompts parameter twice - microsoft ...Opening a query with a filter in Access 2007 - microsoft.public ... 2) You've applied a filter or sort to the query in ... Access 2007, Query's prompts parameter twice ... Query filter by code - microsoft.public.access.queriesOpening a query with a filter in Access 2007 - microsoft.public ..... easy enough to do in the OpenReport call by using the WhereCondition parameter, but OpenQuery has ... How to Restrict Users to view/go to Query Design/Sql mode in MDE/M ...Access 2007 Disable Mode - microsoft.public.access How to Restrict Users to view/go to Query Design/Sql mode in MDE/M ... Opening a query with a filter in Access 2007 ... Access a query without opening Access - microsoft.public.access ...Opening a query with a filter in Access 2007 - microsoft.public ... Since under Access 2007 reports can no longer be exported to Excel, I'm attempting to open the query ... Adding filter to query - microsoft.public.access.modulesdaovba ...Opening a query with a filter in Access 2007 - microsoft.public ... John Spencer Access MVP 2002-2005, 2007 ... Open the report in design view and ... filter to query ... ... Unable to use filter in datasheet view or add criteria to query in ...Opening a query with a filter in Access 2007 - microsoft.public ... Unable to use filter in datasheet view or add criteria to query in ..... John Spencer Access MVP ... Access 2007 query (large IN statement), alternate approaches ...... is if I try and open the "qryFilter" >>in >>design mode Access 2007 gives ... is a way to build the query using the >>actual filter ... Access 2007 query (large IN statement ... Open a form in filter by form datasheet view from Switchboard ...On 19 Nov 2007 16:27:49 GMT ... Unable to use filter in datasheet view or add criteria to query in ... Open a form in ... microsoft.public.access ... Open a form in filter by ... How to: Apply a Filter When Opening a Form or Report [Access 2007 ...How Do I... in Access 2007 ... tables in the record source of the form or report you are opening. Additionally, the filter query ... Using a VBA Variable to Filter a Query in Access 2007Using a VBA Variable to Filter a Query in Access 2007 ... To begin, open frmScores, a form that gives you a choice between a ... Opening a query with a filter in Access 2007 - microsoft.public ...Since under Access 2007 reports can no longer be exported to Excel, I'm attempting to open the query that the report is based on so that I can expor... How to Filter Table Data in Access 2007 | eHow.com... source such as a form, query, report or table. Table data in Access 2007 may be filtered by using the table's filter ... Reasons Macros Won't Open Forms in MS Access 2007 ... How to: Apply a Filter When Opening a Form or Report - Access ...Support / Access / Access 2007 Developer Reference / Access 2007 Developer ... tables in the record source of the form or report you are opening. Additionally, the filter query ... 7/20/2012 11:54:34 AM
|