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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Field Dilema

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
I have a field that contains an input mask for a short date which seems to work fine when first entering the date. The problem is when a user goes back to edit the field and tries to edit a single digit. For example, there is a date of 9/09/02 and the user wants to change the date to 9/16/02. If the user deletes just the 09 and enters a 16, an error message pops up stating the value isn't appropriate for the mask. Is there a way to code around this? I tried using the code below on the before update event but it doesn't work.

Dim strEnteredValue As Variant

strEnteredValue = txtDateofService.Value

If IsNumeric(strEnteredValue) = True Then
Me.txtDateofService.Value = Format(strEnteredValue, "Short Date")
End If
 
zp162002

Looks like the mask is d/mm/yy

so...

16 is NOT a valid month.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I just checked the Short Date mask and it is set for mm/dd/yyyy but the user can enter only six numbers (ex. 091602) and the date will be formatted. Should I take out the input mask and try to code the format. I did try this before but unless the user includes slashes in the date, the value will not be accepted.
 
The problem is with the YEAR portion WHEN YOU ARE EDITING.

Your Short Date is
9/9/2004

When you EDIT using the mask 99/99/00
9/16/2004

WILL NOT WORK unless you ALSO select the 20 of 2004
9/16/04

:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Ok that makes sense. My next question is there a way to code the before update event so a user can either enter 6 digits that will be formatted to a short date or edit either the month, day, or year of a pre-existing date without retyping the entire date? I hope that made sense.
 
Is Y2K that far in the past? Your users ought to ALWAYS use a full year. Change your mask to 99/99/0000!

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top