Setting the year part of a date for data entry (1 Viewer)

raziel3

Registered User.
Local time
Today, 06:10
Joined
Oct 5, 2017
Messages
275
When doing data entry you can enter the month and day and Access will fill out the year, which is based on the PC's date.

I have a backlog of data entry, how to set the year part of the date to the previous year, 2021 or even 2020 when doing data entry. I know you can change the PC's date and it will do this but can I set up a text box or something instead of having to go into the PC settings?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:10
Joined
Oct 29, 2018
Messages
21,473
If you want to use a Textbox instead of the PC settings, then you'll also probably need to use some code to refer to that Textbox when you enter a date on another Textbox.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:10
Joined
Feb 19, 2002
Messages
43,275
Add an unbound textbox to the header of the form so it will work for continuous as was as single record entry. In the load event of the form set the value to the current year.

Me.txtDefaultYear = Year(Date())

Then, if you want to use a different year, manually enter the default.

You can't stop Access from "helping" you so you have to override its help. This can be dangerous so here's the simple way. In the AfterUpdate event of the date entry control, Substitute the defaultYear for whatever is in the control

Me.SomeDate = Me.txtDefaultYear & "/" & Format(Me.SomeDate, "mm/dd")

The harder way is to use the Change event of the Me.SomeDate control. capture each character and when the user enters the second "/", concatenate the default year.

NEITHER method allows the user to enter some records with a different year than others. All rows must end up with the same year.
 

Users who are viewing this thread

Top Bottom