如何在MS Access 2003查询报表中使用变量 [英] How to use variables in MS Access 2003 Query for reports

查看:89
本文介绍了如何在MS Access 2003查询报表中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表适配器中编写了以下查询以获取报告.

I had written following query in table adapter for report.

SELECT     RTGSEntries.ReceiptDate, RTGSEntries.ReceiptNo, RTGSEntries.DepositorName, RTGSEntries.DepositorContact, RTGSEntries.AccountNo, 
                      RTGSEntries.AccHolderName, Banks.BankName, Branches.BranchName, RTGSEntries.IFCS, RTGSEntries.Fees, RTGSEntries.Amount, 
                      @Start AS FromDate, @End AS ToDate
FROM         ((RTGSEntries INNER JOIN
                      Banks ON RTGSEntries.BankId = Banks.BankId) INNER JOIN
                      Branches ON RTGSEntries.BranchId = Branches.BranchId)
WHERE     (RTGSEntries.ReceiptDate BETWEEN @Start AND @End)


当我执行查询(在查询生成器中)时,出现此错误


When I executing query (in query builder) i''m getting this error

Error in SELECT clause: expression near '@'.
Error in WHERE clause near '@'.
Unable to parse query text.



请帮助我....提前



pls help me.... thx in advance

推荐答案

要在MS Access 2003查询中声明变量,您需要采用以下方式:
To declare variables in MS Access 2003 query, you need to do it in this way:
PARAMETERS dStart DateTime, dEnd DateTime;
SELECT ... dStart AS DateFrom, dEnd AS DateTo
...
WHERE ... BETWEEN #dStart# AND #dEnd#


这篇关于如何在MS Access 2003查询报表中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆