InputMask for Number Fields (Leo)

G

Guest

Hi,
I have a control for Vouchers on a form whose input mask needs to be "Year"999
I mean the first four digit show the year and the next 3 digit show voucher
no. e.g. 2007020. The input mask "2007"999 did not work.
Is there any way?! I want the user only input the voucher no. (not the year)
 
G

Guest

In the text box let the user enter only the voucher no, and on the
AfterUpdate event of the text box write the code that add the Year to the
voucher no.

Me.[voucher no Text Box name] = Year(Date()) & Me.[voucher no Text Box name]
 
A

Al Campagna

Leo,
You should store the VoucherYear, and the VoucherSeqNo as two fields, and concatenate
them "on the fly" whenever you need to display the full VoucherID.
*But, you should not be allowing manual entry, or access by the user to this field

Given a new record...
VoucherYear could have a Default Value of
= Year(Date)
VoucherSeqNo could have a Default Value of...
= NZ(DMax("[VoucherSeqNo]","tblYourTable")) + 1
So... when creating a new record, both values could be established "auto-magically",
and just concatenated in a calculated field for display to the user.
= VoucherYear & VoucherSeqNo
Since you saved the Year and the Seq, you can always recalculate the VoucherID, in any
subsequent form, query, or report.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
G

Guest

Thanks a lot ,
I dont want to create another field and want year to be part of voucher no,
so ,I adopted your hint in this way;
in afterUpdate event on my Voucher control, I put this;
lngYear = Clng(Year(Date)) *1000
me.VoucherControl = Me.VoucherControl + lngYear
on validation rule ; <= Year(Date)&999

keep on helping.
--
Thans & Best regards
Leo, InfoSeeker


Al Campagna said:
Leo,
You should store the VoucherYear, and the VoucherSeqNo as two fields, and concatenate
them "on the fly" whenever you need to display the full VoucherID.
*But, you should not be allowing manual entry, or access by the user to this field

Given a new record...
VoucherYear could have a Default Value of
= Year(Date)
VoucherSeqNo could have a Default Value of...
= NZ(DMax("[VoucherSeqNo]","tblYourTable")) + 1
So... when creating a new record, both values could be established "auto-magically",
and just concatenated in a calculated field for display to the user.
= VoucherYear & VoucherSeqNo
Since you saved the Year and the Seq, you can always recalculate the VoucherID, in any
subsequent form, query, or report.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
G

Guest

Great,
I got your hint and made this on AfterUpdate;
lngYear = Clng(Year(Date))*1000
me.VoucherControl = me.VoucherControl + lngYear
keep on nice helping.
--
Thans & Best regards
Leo, InfoSeeker


Ofer Cohen said:
In the text box let the user enter only the voucher no, and on the
AfterUpdate event of the text box write the code that add the Year to the
voucher no.

Me.[voucher no Text Box name] = Year(Date()) & Me.[voucher no Text Box name]

--
Good Luck
BS"D


Leo said:
Hi,
I have a control for Vouchers on a form whose input mask needs to be "Year"999
I mean the first four digit show the year and the next 3 digit show voucher
no. e.g. 2007020. The input mask "2007"999 did not work.
Is there any way?! I want the user only input the voucher no. (not the year)
 
J

John W. Vinson

Great,
I got your hint and made this on AfterUpdate;
lngYear = Clng(Year(Date))*1000
me.VoucherControl = me.VoucherControl + lngYear

You can save a step - the Year() function already returns the year number as a
Long Integer. You don't need CLng().

John W. Vinson [MVP]
 

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