Customizing date autocomplete

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a booking form with date fields in it. Typing in the month and day
triggers auto-complete for the current year, which is fine if the date really
is for the current year. I'd like to customize this so that if the month/day
is less than the current date, it will auto-complete with current-year+1. I
will still need to be able to complete the date manually, of course, if the
year is actually current+2 or greater, but this is a relatively rare
occurrence.
 
You cannot alter the way Access plays with the dates, spinning them around
to try to make sense of them.

However, you could use the AfterUpdate event procedure of the control to add
a year if the date is already past. Example:

Private Sub OrderDate_AfterUpdate()
If Me.OrderDate < Date Then
Me.OrderDate = DateAdd("yyyy", 1, Me.OrderDate)
End If
End Sub
 
Thanks, Allen. That works perfectly.

Allen Browne said:
You cannot alter the way Access plays with the dates, spinning them around
to try to make sense of them.

However, you could use the AfterUpdate event procedure of the control to add
a year if the date is already past. Example:

Private Sub OrderDate_AfterUpdate()
If Me.OrderDate < Date Then
Me.OrderDate = DateAdd("yyyy", 1, Me.OrderDate)
End If
End Sub
 
Back
Top