By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,163 Members | 905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,163 IT Pros & Developers. It's quick & easy.

mask a credit card number in table

imrosie
100+
P: 222
Hello,

I'm trying to figure out how to store only the last 4 digits of a credit card number in a 'Payments' table. paymentid is the primary key, not credit card number. I tried using the 'password' in the first field of the input mask, with;;
Then I can't see anything...

does anyone have a simple solution to this. I don't want to 'see' the entire number, just the last 4 when viewing the datasheet or pulling up the old payment record.. thanks

Rosie
Aug 12 '07 #1
Share this Question
Share on Google+
7 Replies


ADezii
Expert 5K+
P: 8,669
Hello,

I'm trying to figure out how to store only the last 4 digits of a credit card number in a 'Payments' table. paymentid is the primary key, not credit card number. I tried using the 'password' in the first field of the input mask, with;;
Then I can't see anything...

does anyone have a simple solution to this. I don't want to 'see' the entire number, just the last 4 when viewing the datasheet or pulling up the old payment record.. thanks

Rosie
  1. Hide the Credit Card Column in Table Datasheet View.
  2. Create a Query which exposes only the last 4 digits of the Credit Card in a Calculated Field as indicated below:
    Expand|Select|Wrap|Line Numbers
    1. Card: Right([Credit Card],4)
  3. View the Query, not the Table.
Aug 12 '07 #2

missinglinq
Expert 2.5K+
P: 3,532
Hey, Rosie! You say you only want to store the last four digits of the CC number in your table, but that wouldn't do you much good, would it? I would think, from your overall post, that you need to store the entire CC number, but you only want the last four digits "readable" in your table.

What I'd do, I think is have separate fields for the first part of the CCN, which you want hidden (call it CCHidden) , and the second part, which you want to be able to read (call it CCShow.) In the table definition of the first, to be hidden field (CCHidden) make the Input Mask Password.

Next, make a query using the Query Design View. After placing all the fields in the Query Grid go into a blank field and in the Field box enter:

CCEntire: CCHide & CCShow

If you run the query you'll see both halves of the CCN and the entire CCN. The entire CCN will be in plain text in the query, but stored in the table will only be the two halves, with the first half unreadable.

You can now use the query as the Record Source for your table, and if you want to compare a CCN that the user enters against the stored CCN you'd do something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CompareCCN_AfterUpdate()
  2.  If CompareCCN <> CCEntire Then 
  3.   MsgBox "Doesn't match!"  'or whatever you want to do if no match
  4.  End If
  5. End Sub
  6.  
This will compare the entered CompareCCN against the query field CCEntire, then you can take whatever action. The important thing is, the CCEntire, which is all in plain text, doesn't have to appear on the form! The fact that it's part of the query allows you to compare the entered number to CCEntire.

If you're playing around in the world of credit cards, you might want to take a look at this sample db from Allen Browne. He has routines for validting CCNs>

http://allenbrowne.com/CCValid.html

Linq ;0)>

Sorry, ADezii, got distracted mid post!
Aug 12 '07 #3

ADezii
Expert 5K+
P: 8,669
Hey, Rosie! You say you only want to store the last four digits of the CC number in your table, but that wouldn't do you much good, would it? I would think, from your overall post, that you need to store the entire CC number, but you only want the last four digits "readable" in your table.

What I'd do, I think is have separate fields for the first part of the CCN, which you want hidden (call it CCHidden) , and the second part, which you want to be able to read (call it CCShow.) In the table definition of the first, to be hidden field (CCHidden) make the Input Mask Password.

Next, make a query using the Query Design View. After placing all the fields in the Query Grid go into a blank field and in the Field box enter:

CCEntire: CCHide & CCShow

If you run the query you'll see both halves of the CCN and the entire CCN. The entire CCN will be in plain text in the query, but stored in the table will only be the two halves, with the first half unreadable.

You can now use the query as the Record Source for your table, and if you want to compare a CCN that the user enters against the stored CCN you'd do something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CompareCCN_AfterUpdate()
  2.  If CompareCCN <> CCEntire Then 
  3.   MsgBox "Doesn't match!"  'or whatever you want to do if no match
  4.  End If
  5. End Sub
  6.  
This will compare the entered CompareCCN against the query field CCEntire, then you can take whatever action. The important thing is, the CCEntire, which is all in plain text, doesn't have to appear on the form! The fact that it's part of the query allows you to compare the entered number to CCEntire.

If you're playing around in the world of credit cards, you might want to take a look at this sample db from Allen Browne. He has routines for validting CCNs>

http://allenbrowne.com/CCValid.html

Linq ;0)>

Sorry, ADezii, got distracted mid post!
Not a problem, ling. I like your solution better anyway.
Aug 12 '07 #4

imrosie
100+
P: 222
Not a problem, ling. I like your solution better anyway.
Thanks missinglinq,

I'm going off to try this now. You're right...I do need to store the entire number, but don't want anything but the last 4 digits to show, that is what I meant...slip of the verbiage.

Anyway, I'll post back when I get this going. thanks too ADezii,
since you liked Missinglinq's solution, that's what I'll do.
Rosie
Aug 12 '07 #5

ADezii
Expert 5K+
P: 8,669
Thanks missinglinq,

I'm going off to try this now. You're right...I do need to store the entire number, but don't want anything but the last 4 digits to show, that is what I meant...slip of the verbiage.

Anyway, I'll post back when I get this going. thanks too ADezii,
since you liked Missinglinq's solution, that's what I'll do.
Rosie
Always a pleasure to do business with a lady. I'm quite sure that ling feels the same way!
Aug 12 '07 #6

imrosie
100+
P: 222
Always a pleasure to do business with a lady. I'm quite sure that ling feels the same way!
ADezii, what kind words,,,,,'a lady'...I try always to be that. Anyway, I've spoken with my Order dept. regarding the storing of the ccnum....they actually don't want to store the full number because of security.

What they really need is a way to capture the last 4 digits for preparing the invoice. Although this isn't complete, would something like this in the control work?:

Expand|Select|Wrap|Line Numbers
  1. ccnum = right$(trim$(ccnum),4)
I'd like to have this show up on the receipt:****-****-****-1234

Better suggestions are certainly welcome. thanks in advance,
Rosie
Aug 13 '07 #7

missinglinq
Expert 2.5K+
P: 3,532
Not be obtuse, as I've never worked in commerce, but if the CCN isn't stored anywhere, how is the customer charged? And yes, your code should pull the last four characters of any srtring.

Linq ;0)>

FYI, according to a report I saw a month or two ago, a recent study showed that over 95% of all theft of CCNs didn't come thru theft by computer but rather the old fashioned way, by someone walking off with hard copies!
Aug 13 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.