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

Custom Input Mask on Access Form

Status
Not open for further replies.

bernardb

Vendor
May 22, 2002
5
US
I'm trying to build an input mask that allows the user to enter a 4 digit number and the mask will format it as follows:

M-xxxx-08

Where the x's are the number entered by the user, the "M-" is pre-formatted and the "08" represents the current year, also pre-formatted.

So far I have been able to get it to produce "M-xxxx-" with this mask: M-"####;0;_ But I don't know how to get it to enter the current year.

Any help would be greatly appreciated,


 
I can see now that my post was not entirely clear, sorry about that. I want the mask to enter the current year, no matter what year it is, not just this current year of '08.
 
Use the DATEPART function with DATE().

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
I must be a real dim bulb because every iteration I have tried comes out looking something like this:

"M-"####"- + D"a"teP"a"rt(yy",\Da"te())" or variations of same.

All the extra quotes and |'s are added by Access when I exit the field.

What am I missing?
 
OK, this works, but maybe not what you want.
Leave the Format as simply 0000.
Add this code to the text box LostFocus event:
Code:
Private Sub Text0_LostFocus()

    Text0 = "M-" & Text0 & "-" & Right(DatePart("yyyy", Date), 2)
    
End Sub

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top