By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

Crosstab query

P: n/a
I'm using Access 2003 and was wondering if it is possible to have a
paramater selection within a crosstab query so that I wouldn't need to build
a new table.

I have a select query that I'm using to build the crosstab query from. In
the select query I'm prompting for a specific quarter but when I go to run
the crosstab it doesn't seem to like the parameter that has been put on the
select query and returns a message of "The Microsoft Jet database engine
does not recognize '[Which Period?]' as a valid field name or expression."

Any suggestions would be greatly appreciated.
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Tue, 26 Apr 2005, "Judy" <ju*********@nortel.com> wrote:
I have a select query that I'm using to build the crosstab query from. In
the select query I'm prompting for a specific quarter but when I go to run
the crosstab it doesn't seem to like the parameter that has been put on the
select query and returns a message of "The Microsoft Jet database engine
does not recognize '[Which Period?]' as a valid field name or expression."


When I need any kind of query with user input, I base the query
on an entry box on a form, and point the query criteria line to
the box on the form, such as

[forms]![PrinterForm]![EnterName]

If you are already doing that... ignore this
John Thomas Smith
http://www.direct2usales.com
http://www.pacifier.com/~jtsmith
Nov 13 '05 #2

P: n/a
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 ***
Nov 13 '05 #3

P: n/a
Judy,
This worked on a database I use to track the money I spend:
PARAMETERS [Which Year?] Short;
TRANSFORM NZ(Sum(HOURS_FACT_TBL.EST_NET_PAY),0) AS TOTAL_EST_NET_PAY
SELECT PROJECT_LKP.NAME AS PROJECT, NZ(Sum(HOURS_FACT_TBL.EST_NET_PAY),0) AS
TOTAL_EST_NET_PAY1
FROM (HOURS_FACT_TBL INNER JOIN SS_DATE_TBL ON HOURS_FACT_TBL.DATE_WORKED =
SS_DATE_TBL.DATE) INNER JOIN PROJECT_LKP ON HOURS_FACT_TBL.PROJECT =
PROJECT_LKP.ID
WHERE (((SS_DATE_TBL.YEAR)=[Which Year?]))
GROUP BY PROJECT_LKP.NAME
PIVOT SS_DATE_TBL.GCAL_QTR_TEXT In ("Q1","Q2","Q3","Q4");

If I changed the spelling of [Which Year?] in any way in either of the two
places where it is used Jet will kick the error you talked about.
--
Alan Webb
kn*******@SPAMhotmail.com
"It's not IT, it's IS"

"Judy" <ju*********@nortel.com> wrote in message
news:d4**********@zcars129.ca.nortel.com...
I'm using Access 2003 and was wondering if it is possible to have a
paramater selection within a crosstab query so that I wouldn't need to
build
a new table.

I have a select query that I'm using to build the crosstab query from. In
the select query I'm prompting for a specific quarter but when I go to run
the crosstab it doesn't seem to like the parameter that has been put on
the
select query and returns a message of "The Microsoft Jet database engine
does not recognize '[Which Period?]' as a valid field name or expression."

Any suggestions would be greatly appreciated.

Nov 13 '05 #4

P: n/a
another suggestion is to wrap your criteria in Eval("")..... thus
Eval("[Which Period?]"). as mentioned above, crosstab queries are
temperamental. anytime a crosstab query, or a query that the crosstab
query is based on, uses a parameter value, you must use the Eval()
function. if you use this, you won't need to use the Parameter property
for the query.

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.