I need a formula that finds a departure date between two given dates where the departure occurs later than a given time

Course

Board Regular
Joined
Aug 7, 2014
Messages
144
Im using Access 365 2016.

I need a formula that finds a departure date between two given dates where the departure occurs later than a given time.


I have tried this formula but it doesnt work:

Code:
<code>Between [date1] And [date2] Where (TimeValue([Date1] > 09:30 </code>
Thank you
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Is this for a select statement, or for VBA code?
 
Upvote 0
Is this for a select statement, or for VBA code?

Im building a formula in the expression builder.

The expression is referencing controls on a form. When these controls have data entered into them I run a command that opens a query.
 
Upvote 0
The formula i quoted above is a simpler way of writing the formula below. The formula below is the exact formula that I have in the expression builder:

(Between [Forms]![Flights]![cboDeparture1]
And
[Forms]![Flights]![cboDeparture2])
And
(TimeValue([Forms]![Flights]![cboDeparture1])>[Forms]![Flights]![cboGreaterThanTime])
 
Upvote 0
Sorry If ive confused you. The code in the post above above should be

Between [Forms]![Flights]![cboDate1]
And
[Forms]![Flights]![cboDate2]
And
TimeValue([Forms]![Flights]![cboDate1])>[Forms]![Flights]![cboGreaterThanTime]
 
Upvote 0
By doesn't work, do you mean the formula returns an error, or just returns incorrect data?
 
Upvote 0
A Clarification:
I asked a similar question earlier but i I made a mess of the code so Im asking the question again.


I need to write an expression in the expression builder that finds a departure date between two given dates that is greater than a given time.

I have three controls on a form called Flights. The controls are named cboDeparture1, cboDeparture2 and cboGreaterThanTime. Both cbo.Departure controls are formatted as dd/mm/yyyy hh:nn and the cbo.GreaterThanTime control is formatted as hh:nn


I have referenced these controls as criteria in the Departure field of the Query so that they will filter the Query based on whatever is entered into the controls.

I have tried this code but it doesnt work. It returns an error message saying the form hasnt the correct syntax.

Code:
Between [Forms]![Flights]![cboDeparture1]
And
[Forms]![Flights]![cboDeparture2]
And
TimeValue([Forms]![Flights]![cboDeparture1])>[Forms]![Flights]![cboGreaterThanTime])
Can anyone help.

Thank you
 
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top