Square brackets should work:
'==================
Sub RefreshCommandText()
'refresh pivot table command text,
'including prompt for date range
Dim dtmStart As Date
Dim dtmEnd As Date
dtmStart = InputBox("Start Date")
dtmEnd = InputBox("End Date")
ActiveWorkbook.PivotCaches(1).CommandText _
= "SELECT *" & Chr(13) & "" & Chr(10) & _
"FROM `c:\customer service.mdb.mdb`" _
& ".[Y-Delivery Status] WHERE ((([Y-Delivery Status].Dlvry_Status)
Between #" _
& dtmStart & "# And #" & dtmEnd & "#))"
End Sub
'=================================
Thank you very much!
This seems like it should work, but isn't.
Then again, I am a novice at code writing so maybe my syntax isn't quite
right.
How do you account for spaces?
EX. my db is customer service.mdb
My Access query is Y-Delivery Status
and the date field I am using parameters in is Dlvry_Status.
Thanks again,
Allyson
:
You could create a pivot table from the query without parameters. Then
use code similar to the following, to prompt for a date range:
'====================================
Sub RefreshCommandText()
'refresh pivot table command text,
'including prompt for date range
Dim dtmStart As Date
Dim dtmEnd As Date
dtmStart = InputBox("Start Date")
dtmEnd = InputBox("End Date")
ActiveWorkbook.PivotCaches(1).CommandText _
= "SELECT *" & Chr(13) & "" & Chr(10) & _
"FROM `c:\Test.mdb`" _
& ".qryInvDate WHERE (((qryInvDate.InvDate) Between #" _
& dtmStart & "# And #" & dtmEnd & "#))"
End Sub
'==============================
AllyOop wrote:
I am trying to create an Excel pivot table from a simple Access query with 2
parameters, using MS Query. (start date, end date)
I have been able to create the pivot table from the query easily without the
parameters and I have been able to run the query by itself with the
parameters, but when I try to run the pivot off the edited query with
parameters, I get an error message that parameters are not allowed.
Is there some way around this?
Thank you.