Ms Access input mask

Trying to create an input mask to only show the last 4 numbers on a report. one the form i have 2 fields one called CardType and other called CardNum. so ill need it to first set a input mask from below for Cardnum based on the CardType which will show all of the card number as in example below which is a table called tblCardList

Credit Card                 Sample Number
Visa                         4111-1111-1111-1111
MasterCard                 5500-0000-0000-0004
American Express        3400-0000-0000-009
Diner's Club                3000-0000-0000-04
Carte Blanche        3000-0000-0000-04
Discover                6011-0000-0000-0004
en Route               2014-0000-0000-009
JCB                       3088-0000-0000-0009  

then need it to show on the report like this
Credit Card                 Sample Number
Visa                         xxxx-xxxx-xxxx-1111
MasterCard                xxxx-xxxx-xxxx-0004
American Express        xxxx-xxxx-xxxx-009
Diner's Club                xxxx-xxxx-xxxx-04
Carte Blanche        xxxx-xxxx-xxxx-04
Discover                xxxx-xxxx-xxxx-0004
en Route               xxxx-xxxx-xxxx-009
JCB                       xxxx-xxxx-xxxx-0009  
Blueice13085Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

als315Commented:
to only show the last 4 numbers on a report
Do you need input or output mask? Are you talking about report or form?
For output you can use function like this:
Function card_mask(A As String) As String
Dim B() As String
B = Split(A, "-")
card_mask = "xxxx-xxxx-xxxx-" & B(3)
End Function
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Just noting here that if ... you are talking about a report, an Input Mask has no effect whatsoever.  I think you mean the Format property. Even on a Form, an Input Mask has no effect on how data is display ... once data is entered in a control with a mask.  Again, Format affects the display of data.

So, you should probably clarify this a bit ...

mx
Blueice13085Author Commented:
alright what i want is in a form i want the whole numbers to show up also on the form when i select card type then changes a input mask like i explained above cards have different amout of numbers so i want so i.e i click on Visa then changes an input mask called Visa which is 1234-1234-1234-1234 to get that i just typed 1234123412341234
on the report i want it to show the last set of numbers and X out the rest i.e Visa xxxx-xxxx-xxxx-1234
American Express xxxx-xxxx-xxxx-123
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Armen Stein - Microsoft Access MVP since 2006President, J Street TechnologyCommented:
I also need to point out that an Access back-end database isn't secure enough to store credit card numbers safely, especially if you also store other components of the transaction like expiration date and CVV in the same database.  So I hope you're storing the data in a more secure back-end database like SQL Server.
als315Commented:
Check example. There are some limitations when you are changing mask: you can't do it for existing data. You should always at first select card type, only then input data.
DB.accdb

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Well ... Armen beat me to it ... but I totally agree.  I will just make a blanket statement:
Rethink storing SS and/or CC numbers in a Access db.  The security just is not there.  Even if it's just for your own personal use ...if some one steals a laptop ... and takes it to the 'guy downtown' ... and they get your physical hard drive ... they can hack ANY Windows password of ANY strength in a matter of seconds ... let alone an Access DB password.

Now, having said that ... for academic reasons, we can continue this discussion as to how we would ... do what you need :-)

mx
Blueice13085Author Commented:
sorry requested attention on this i selected the wrong person for the solution sorry
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Just to note that you can simply the code down to


Function card_mask(A As String) As String
    card_mask = Split(A, "-")(3)
End Function

An elegant solution in any case ...

mx
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
OOPS ... I mean:


Function card_mask(A As String) As String
    card_mask = "xxxx-xxxx-xxxx-" & Split(A, "-")(3)
End Function

Although I just noticed (well, I knew this) that all of my AMEX cards are formatted (on the card) as:

1234-12345-12345
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Opps again.  The AMEX format is


1234-123456-12345

However, it really doesn't matter for what you are trying to do.

mx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.