Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query by date you enter

Status
Not open for further replies.

AccessXP

IS-IT--Management
Jan 29, 2002
132
0
0
How can I make access ask for the dates I need for the Query that is being printed?

 
Morning x/p
Design view of your query, in the criteria section of the date field you want put:
Between [Enter begin date] And [ Enter end date]
(You can put anything you want between the brackets.)
Run the query and a "Enter Parameter value" box will display. Enter date and click ok or press enter and a second box will appear asking for the end date.
Jim
 
Thanks for the help I could not remember the exact line of code.
 
I am in the same boat, trying to enter a date as a parameter for a report. However, using the brackets in my SQL statement doesn't seem to work. Every time I try it I receive "The Microsoft Jet database does not recognize '[Enter begin Date]' as a valid field name or expression." Any ideas why I'm getting that?
 
I don't use SQL for editing so I'm not real good at coding but be sure you have the
Like[Enter begin date]
in the SQL.
Jim
 
JohnnyProd,
If you're using this in a VB application with ADODB recordsets, try this.

From MS ACCESS:

SELECT *
FROM tblWhatever
WHERE (((tblWhatever.BeginMonth)=[Enter begin date]));

To

rs.source = "SELECT * FROM tblWhatever WHERE (((tblWhatever.BeginMonth)= #" & chr(34) & begindate & chr(34) & "#))"

where begindate is a variable you prompt the user for, for the query beginning date.

The chr(34) inserts the ASCII double quote into the query and the pound sign tells it to match date values.

 
JohnnyProd,
Try creating a new query. In design view, In the criteria box of the date field, for a particular date enter:

Like [Enter date]

for records between two dates:

Between [Enter First date] and [Enter second date]

It will add to your SQL automatically, without editing.
Also, you need at least one valid record for all fields used to retrieve the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top