> On Fri, 16 Mar 2007 01:51:08 -0700, Dagmar
> <Dagmar[ at ]discussions.microsoft.com> wrote:
>
> >
> >Now, that I can read the SQL-Query I would like to change it.
> >e.g. the original query is like this:
> <snip>
>
> >WHERE (L.Beginn Between '1.1.2006' And '31.12.2006')
> >
> >It would be nice to change the L.Beginn Date in the end. However, I copied
> >the SQL-Query String above and added the
> >"?ActiveSheet.PivotTables(1).PivotCache.CommandText" in the front.
> >Unfortunately this does not work ("Syntax error ..."). I also tried less
> >complex SQL-Queries which do work.
> >
> >Are there any better/more comfortable ways to change this query?
> >
>
> Nope. There are no good ways. There's an extra space, or maybe not enough
> spaces, or something else that's really hard to find. It would be nice if
> there was an easier way.
>
> Maybe this way is a *little* easier. I tend to use the Replace method, e.g.
>
> ActiveSheet.PivotTables(1).PivotCache.CommandText =
> Replace(ActiveSheet.PivotTables(1).PivotCache.CommandText, "WHERE (L.Beginn
> Between '1.1.2006' And '31.12.2006')", "WHERE (L.Beginn Between '1.1.2007'
> And '31.12.2007')")
>
> You still have to get the ReplaceWith syntax right, but it takes the rest of
> the SQL statement out of the picture. Make sure you include enough text in
> the ReplaceWhat argument so that you don't inadvertantly replace more than
> you bargained for.
>
> --
> Dick Kusleika
> Microsoft MVP-Excel
>
http://www.dailydoseofexcel.com>