Office & Productivity Software forum

General discussion

MS Access - Between Dates queries using variables from forms

by sheilasabado / June 13, 2010 8:05 PM PDT

I have a table with [Call Start] as Date/Time General Date which has data from March 30, 2010 until May 9, 2010. I want to create a query wherein I can get a date range from user given starting and ending date from a Form (GenForm):

User enters ff value in GenForm:

StartDate = 07-Apr-10
EndDate = 09-May-10

This is my query in MS Access Design View

Field: Format([Call Start],"Short Date")
Criteria: Between Format([Forms]![GenForm]![StartDate], "Short Date") And Format([Forms]![GenForm]![EndDate], "Short Date")
Result: It gives me data only for Apr 7, April 8, April 9, May 7, May 8 and May 9.

I think it only looks at the days of the date and not the entire date. Anyone can help me, please?

Post a reply
Discussion is locked
You are posting a reply to: MS Access - Between Dates queries using variables from forms
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: MS Access - Between Dates queries using variables from forms
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -

You're nearly there. Don't format, just compare the dates.

Field: any date/time field
Criterion for the field: >= [Forms]![GenForm]![StartDate] and <= [Forms]![GenForm]![EndDate]

Your thought about what it does are right. The format results in a string, so the comparison is a string comparison, not a date comparison. And "10" isn't between "07" and "09", is it. So any string starting with "10" isn't between "07-" and "09-".


Collapse -
by gisquared / March 23, 2012 6:05 AM PDT
In reply to: Solution.

This exactly what I needed... thank you... I changed it a bit though. for us...we have a page where we always want two weeks out from a single date so I used:

>=[Forms]![Main Menu]![Monday Date] And <=[Forms]![Main Menu]![Monday Date]+14

Works like a charm.

Popular Forums
Computer Help 49,613 discussions
Computer Newbies 10,349 discussions
Laptops 19,436 discussions
Security 30,426 discussions
TVs & Home Theaters 20,308 discussions
Windows 10 360 discussions
Phones 15,802 discussions
Windows 7 7,351 discussions
Networking & Wireless 14,641 discussions


Big screens for the big game

Still looking for the best TV deals ahead of Sunday's game? Here are our top three big screen picks.