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

Display a year

Status
Not open for further replies.

GerryGoldberg

Technical User
Apr 12, 2001
55
I have a form that is based on a table that contains a numeric field that represents a year value. I would like the user to be able to enter two OR four digits for the year but have the form always display a four digit year. I have tried various combinations for Format and Input Mask but can't seem to get it right. Can anyone steer me in the right direction.

Thanks,

 
You'll have to write the logic yourself. You'll have to figure out how to handle the two-digit years: there's got to be break point for making some of them start 20 and some of them start 19, unless you want them all to start 19. You'll probably want to do some overall validation, to make sure that all values are within a certain range.

I would say, junk it as an idea. First off, dates should be stored in date fields. Second, this is a lot of code to write. Third, we all saw what a mess two-digit years created a few years ago, and there's no reason to revisit that. Sometimes users have to learn to deal with the way software functions. Just require that the value be between a give range or use a date field, would be my advice.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Since it's a numeric field I don't believe formatting it is going to help. Try this to see if it works for you.

On the AfterUpdate event of the field type something like this (where txtintNumber is the name of your text box):

Private Sub txtintNumber_AfterUpdate()

If (txtintNumber < 100) Then txtintNumber = 2000 + txtintNumber

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top