Crosstab queries in Access are temperamental that way. The fix is to
move your parameter from the underlying query to the crosstab query.
You can place a parameter in any of the RowHeading fields for the
crosstab query.
Right-click in the body of the query next to the table listing. From
the dropdown menu select Parameters. This will give you a grid where
you enter your parameter. Give your parameter a name and select the
datatype (text, number, date). Then in the Rowheading field where you
want to use this parameter you write this in the Criteria section under
that column
[Name]
Put the name of your parameter that you entered in the grid in the
criteria section of the RowHeading column you want to filter, and you
have to surround this with left and right square brackets [ ].
Another way to set a parameter in a query (crosstab query) is to write a
function in a standard module (click on Modules in the database window
to get to a standard module). This is useful if you have a vba routine
which needs to pass a parameter to a crosstab query. Interestingly, I
have not be able to pass params to crosstab queries using DAO. But the
function method works fine. In the module your write a simple function
like this
Function GetName() As String
GetName = strName
End Function
strName would be a global string variable. You set its value in code
and then access your crosstab query. You could do something simple like
this to set the value of your function - this value will live until you
close your session of Access down.
Sub setValue()
GetName = "Bill"
End Sub
In the crosstab query you would have entered the function name in the
criteria section of the RowHeading Column you want to filter. ...Like
this... setValue()
You have to include the Parentheses. Now open your query. If you have
rows that contain the value "Bill", this will show up in your crosstab
query.
Rich
*** Sent via Developersdex
http://www.developersdex.com ***