Link to home
Create AccountLog in
Avatar of Blueice13085
Blueice13085Flag for United States of America

asked on

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  
Avatar of als315
als315
Flag of Russian Federation image

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
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
Avatar of Blueice13085

ASKER

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
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.
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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
sorry requested attention on this i selected the wrong person for the solution sorry
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
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
Opps again.  The AMEX format is


1234-123456-12345

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

mx