Critera in Crosstab Query

J

Joy

I'm trying to use a form text boxes to set the date critera for my crosstab
query. When I run it I receive a message stating "database engine does not
recognize '[Form]![OpeningPage]![StartDate] as a valid fieldname or
expression".

TRANSFORM Count(ReceiptDetails.[Receipt No]) AS [CountOfReceipt No]
SELECT ReceiptDetails.CDate, Count(ReceiptDetails.[Receipt No]) AS [Total Of
Receipt No]
FROM ReceiptDetails
WHERE ((([ReceiptDetails].CDate) Between [Forms]![OpeningPage]![StartDate]
And [Forms]![OpeningPage]![StartDate]))
GROUP BY ReceiptDetails.CDate
PIVOT ReceiptDetails.Office;

Any help would be great appreciated, this driving me insane
 
A

Allen Browne

Declare the parameters.

In query design view, choose Parameters on the Query menu.
Access opens a dialog.
Enter 2 rows:
[Forms]![OpeningPage]![StartDate] Date/Time
[Forms]![OpeningPage]![EndDate] Date/Time

I have assumed you actually have 2 text boxes you refer to: otherwise the
Between operator doesn't make sense.

More info:
http://allenbrowne.com/ser-67.html#Param
 
J

Joy

Excellent, works well. Thanks Heaps for that. Have a great day.
--
Thank Heaps


Allen Browne said:
Declare the parameters.

In query design view, choose Parameters on the Query menu.
Access opens a dialog.
Enter 2 rows:
[Forms]![OpeningPage]![StartDate] Date/Time
[Forms]![OpeningPage]![EndDate] Date/Time

I have assumed you actually have 2 text boxes you refer to: otherwise the
Between operator doesn't make sense.

More info:
http://allenbrowne.com/ser-67.html#Param

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Joy said:
I'm trying to use a form text boxes to set the date critera for my
crosstab
query. When I run it I receive a message stating "database engine does not
recognize '[Form]![OpeningPage]![StartDate] as a valid fieldname or
expression".

TRANSFORM Count(ReceiptDetails.[Receipt No]) AS [CountOfReceipt No]
SELECT ReceiptDetails.CDate, Count(ReceiptDetails.[Receipt No]) AS [Total
Of
Receipt No]
FROM ReceiptDetails
WHERE ((([ReceiptDetails].CDate) Between [Forms]![OpeningPage]![StartDate]
And [Forms]![OpeningPage]![StartDate]))
GROUP BY ReceiptDetails.CDate
PIVOT ReceiptDetails.Office;

Any help would be great appreciated, this driving me insane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top