Date Range Code Needed! (Thanks)

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have a control on my form named WorkDate (No Space)
It's control source is Work Date (Space Between)
On the update event or change event I need to check for a date within the
range below.
If out of this date range , then Message Box, Cancel if possible and not
save until criteria is met.
There is an unbound textbox named AnyDate on my form with it's default value
set to Date()

=CDate([AnyDate])-(Weekday(CDate([AnyDate])))-2 ' Criteria One, The Start
Date
=CDate([AnyDate])-(Weekday(CDate([AnyDate])))+4 ' Criteria Two, The End Date
 
Without more information, it's hard to determine what you're asking. What
problem are you having? Is your code not working as you expect? What is it
doing?

I'm uncertain about what you're trying to accomplish with the code you
posted. It looks like you may be wanting a date range from 2 days before to
4 days after AnyDate. Is that correct? The WeekDay function returns a number
representing the day of the week (Sunday=0, Monday=1, etc). Why are you
subtracting this number from AnyDate?

Carl Rapson
 
Back
Top