尝试获取交叉表以在打开查询时显示提示以允许输入日期范围(开始和结束)(dd-mm-yyyy),以便在运行查询时仅返回此数据
目前正在使用以下代码;
$1
但不能为我的生活绕过" MS Access数据库引擎无法识别' Alphadata。[DateRaised:]'作为有效的字段名称或表达式"问题。
" WHERE"查询的一部分确实可以在其他查询中使用,但它只是在交叉表中应用时才会显示。
有什么建议吗?
答案 0 :(得分:1)
您需要将参数添加到查询中:
PARAMETERS [Start Date] DateTime, [End Date] DateTime;
TRANSFORM Count(AlphaData.Invoice) AS CountOfInvoice
SELECT AlphaData.Reason, Count(AlphaData.Invoice) AS [Total Of Invoice]
FROM AlphaData
WHERE (((AlphaData.DateRaised) Between [Start Date] And [End Date]))
GROUP BY AlphaData.Reason
PIVOT Format([DateRaised],"Short Date");
(注意:参数作为第一行添加,然后在Between
语句中使用)。
我没有意识到这会发生在交叉表中,因为您可以为选择查询键入参数:
SELECT Invoice, Reason, DateRaised
FROM AlphaData
WHERE DateRaised=[Start Date]
答案 1 :(得分:1)
似乎有点混乱。怎么样:
PARAMETERS
[From Date:] DateTime,
[To Date:] DateTime;
TRANSFORM
Count(*) AS CountOfInvoice
SELECT
AlphaData.[Reason],
Sum(AlphaData.[Invoice]) AS [Total Of Invoice]
FROM
AlphaData
WHERE
AlphaData.[DateRaised] Between [From Date:] And [To Date:]
GROUP BY
AlphaData.[Reason]
PIVOT
Format([DateRaised],"Short Date");