input mask or format to put 2009-XXXXX

P

Pat Briggs

I need to put the first number (2009-) in the form and then be able to fill
in the last 5 digits but when I try to put it in it always overwrites the
2009. Is this an input mask or a format problem and how to I input so it is
correct.
 
J

Jack Leach

I wouldn't know how to do this with an input mask or format, but you may be
able to use the BeforeUpdate event of the control:

Private Sub Control_BeforeUpdate(Cancel As Integer)
Me.Controlname = "2009-" & Trim(Me.ControlName)
End Sub

hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
J

Jack Leach

Private Sub Control_BeforeUpdate(Cancel As Integer)
Me.Controlname = "2009-" & Trim(Me.ControlName)
End Sub

Thereagain, if every peice of data going into the field needs to be prefixed
"2009-", I would maybe look at a calculated field. Stuff like this slips
pretty easily into cases where we are storing non-required information.

A calculated field in a query based off the "real" underlying field would
simply prefix the value, which you could then use for all visual
corresondence.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
F

fredg

I need to put the first number (2009-) in the form and then be able to fill
in the last 5 digits but when I try to put it in it always overwrites the
2009. Is this an input mask or a format problem and how to I input so it is
correct.

Neither Input Mask nor Format.
I assume the 2009 represents the year.
What will you do on Jan 1, 2010, and Jan 1, 2011, and ... etc.?

A better solution would be to not add the year until the data is
saved.
Code the control's AfterUpdate event:
Me.[ControlName] = Year(Date) & "-" & Me.[ControlName]

The user enters just xxxxxx. When exiting the control 2009-xxxxxx is
stored in the field (This year. Next year the value is automatically
2010-.).
 
J

John Spencer MVP

You can do this with an input mask, however it is probably a bad idea to do so.

The input mask would look like the following.

"2009-"00000;0;_

That will show 2009-_____ when you go to input. The second argument will
store the "2009-" in the field along with the numbers you have input.

However, in 2010 you will have to edit this input mask if you want 2010 to
appear once the year has become 2010.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
G

GBA

if the user doesn't need to see the 2009- then you can simply add it in the
AfterUpdate event
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top