Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Field Doing Strange Things

Status
Not open for further replies.

nubianqueen

Technical User
Apr 16, 2002
19
0
0
US
I've looked at this issue over and over again, but I don't see it, maybe someone can help me.
I have a date field on my form (FieldA) with this format
"mmm-yyyy" and another date field (FieldB) with the same format. I input this number- 05/01 and it turns to "May-2003" or I enter 5/02 and I still get "May-2003. But on the other hand if I enter 5/2001, everything is all good. I was trying to keep the keystrokes for the user to a minimum. So is there a way for the user to enter 5/01 and value defaults to 5/2001?
I have some code attached and I not sure if it could be part of the problem as well. This is what it looks like:

Private Sub FieldA_AfterUpdate()
If IsNull([FieldA]) Then

Else
TargetDate = DateAdd("m", "12", [FieldA])
End If
End Sub

Appreciate any help. Thanks
 
I'm not sure how to go about fixing it exactly, but the problem is probably being encountered because it is figuring that you are saying may 1st, second, etc. since the normal format is mm/dd/yyyy, so when you say 05/01, it thinks may first, not may of 2001.
 
Access stores full Date values (mm/dd/yyyy) as opposed to just month values (mmm/yyyy). You might try putting some code behind the field (on the onChange or After Update events) that re-formats the entry to mm/dd/yyyy. You can also do field validation here, to the field more flexible, so that it is dummy proof (in case the user decides to enter it in a different format other than the "05/01" format you are shooting for..)

Earnie Eng
 
you could also have 2 drop downs, one with the months and another with values populated x number of years before the current and x number after. That would allow users to select both values from a dropdown and you could then enter the dates using these.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top