Find next date in table

%3CLINGO-SUB%20id%3D%22lingo-sub-2270274%22%20slang%3D%22en-US%22%3EFind%20next%20date%20in%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2270274%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20today%20is%2025th%20December%202021%3CBR%20%2F%3E%3CSPAN%3Eand%20I%20have%20a%20table%20with%20these%20dates%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%5Btbl_dates%5D!%5Bmy_date%5D%3CBR%20%2F%3E01%2F02%2F2024%3CBR%20%2F%3E28%2F06%2F2035%3CBR%20%2F%3E17%2F04%2F2024%3CBR%20%2F%3E24%2F12%2F2021%3CBR%20%2F%3E23%2F05%2F2022%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EHow%20can%20I%20populate%20a%20textbox%20on%20a%20form%20with%20the%20%3CU%3Enext%3C%2FU%3E%20(not%20the%20closest)%20date%20in%20the%20table%3F%3CBR%20%2F%3E*%20It%20should%20be%2023%2F05%2F2022%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2270274%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

If today is 25th December 2021
and I have a table with these dates

[tbl_dates]![my_date]
01/02/2024
28/06/2035
17/04/2024
24/12/2021
23/05/2022

How can I populate a textbox on a form with the next (not the closest) date in the table?
* It should be 23/05/2022

Thanks

 

4 Replies

@karenlorr_uk 

 

What rule applies to the generation of those dates? We can probably guess, or make an assumption, about how you did that, but it is also probably more effective to state the rule directly.

Thanks.

@George Hepworth 

They are just dates stored in a date field in a table.


It's simple to do in a query
SELECT TOP 1 tbl_dates.My_date
FROM tbl_dates
WHERE (((tbl_dates.My_date)>Date()))
ORDER BY tbl_dates.My_date;

Or in a form you can use
DMin("my_date", "tbl_dates", "my_date > Date()")

But I was hoping for a form textbox simple expression
e.g.
=DMax("my_date","tbl_dates")
=DMin("my_date","tbl_dates")

LoL
Mind you it may not be possible.  I'm sure there isn't a DNext



Let's try a different approach, then.

What do YOU mean when you ask for "the Next Date"? Are you looking for a way to generate another date, based on the pattern so far?
Or are you really asking,
"Looking at the record for today's date, what is the subsequent date, available IN THIS TABLE ALREADY, following that date"?

@karenlorr_uk 

> I was hoping for a form textbox simple expression

There is. The expression to use as ControlSource is:

=DMin("my_date","tbl_dates","my_date > Date()")