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!

Running query based on a specific time range. HELP!

Status
Not open for further replies.

setchae

Technical User
Oct 15, 2003
2
0
0
US
I have 4 Date and time picker controls on a form along with a subform. I want records to be displayed based on dates and times selected. I have 2 problems.

1) The date controls are working just fine, but I cannot seem to get the time controls to work. In the criteria section of my query I have:

>=[Forms]![Main]![StartTime] And <=[Forms]![Main]![EndTime]

Since this worked for the date, I thought it may work for the time. Obviously, I was wrong.

2) Is there any way I can have the records show up in the subform based on the user's selections? Currently, the only way I can get it to work is by using a command button to run the query. Once the button is clicked, the query is displayed instead of the records showing up in the subform.


Any help would be greatly appreciated!

Thank you,
Brandon
 
Try: Between [Forms]![Main]![StartTime] And [Forms]![Main]![EndTime] -- You may need to enclose the variables name in pound signs, like this: Between #[Forms]![Main]![StartTime]# And #[Forms]![Main]![EndTime]#
 
Is it possible that your records contain a single date and time stamp? (i.e., 10/14/03 17:30:00) If so, this time is not between 17:00 and 18:00, because short times would refer to Jan. 1 of 1900.

If this is the case, then you need to add your Date and Time fields together, then check to see if your record date is between these new values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top