Customizing date autocomplete

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.
 
A

Allen Browne

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top