How to prompt user input parameters for SQL Queries in Access 2010

Posted by user1848907 on Stack Overflow See other posts from Stack Overflow or by user1848907
Published on 2012-11-24T04:34:30Z Indexed on 2012/11/24 5:04 UTC
Read the original article Hit count: 212

Filed under:
|
|
|
|
SELECT Transactions.TransactionNumber
FROM Transactions
WHERE (((Transactions.Date)>=#11/23/12#)) AND (((Transactions.Date)<=#11/23/12#));

The above code returns all the transaction that happened between the specified dates. But I want those dates to be defined by the user every time the query is executed.

I tried using the [] operators to have the user define the criteria in the WHERE, something like this:

WHERE (((Transactions.Date)>=[Input a Date])) AND (((Transactions.Date)<=[Input a Date]));

But microsoft Access throws a Syntax error message. The same happens when I include the # (date operators) like this

WHERE (((Transactions.Date)>=#[Input a Date]#)) AND (((Transactions.Date)<=#[Input a Date]#));

Is there anopther way to manage dates that I'm not aware of or is asking a user for dates in a query out of the question

© Stack Overflow or respective owner

Related posts about sql

Related posts about database