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

replace text with XXXX for protection

P: 10
I have a textbox that holds credit card numbers. I want to be able to print these numbers in a report but to display X's instead of the numbers. Example if the number is like this : 5262 1234 5678 9012 it would print instead like this
XXXX XXXX XXXX 9012.
Please help
Apr 21 '08 #1
Share this Question
Share on Google+
6 Replies


missinglinq
Expert 2.5K+
P: 3,532
Place an Unbound textbox on your report and as itsControl source use

=String(Len(Replace(CCN," ",""))-4,"X") & Right(CCN,4)

Where CCN is your field holding the credit card number.

Welcome to bytes!

Linq ;0)>
Apr 21 '08 #2

Expert Mod 2.5K+
P: 2,545
I have a textbox that holds credit card numbers. I want to be able to print these numbers in a report but to display X's instead of the numbers. Example if the number is like this : 5262 1234 5678 9012 it would print instead like this
XXXX XXXX XXXX 9012.
Please help
Hi. There are many ways to do this. The simplest I can think of works if the card number is stored as a text string, and it is to extract the last four characters of the card number using the string function Right.

You can use the following directly in the controlsource property of the textbox in your report, changing the name of the textbox to something different to prevent a circular reference to the name of the creditcard number field:
Expand|Select|Wrap|Line Numbers
  1. ="XXXX XXXX XXXX " & Right$([name of your cardnumber field], 4)
If you use this form of display frequently it is a simple matter to make this a custom function which you can call whenever required:
Expand|Select|Wrap|Line Numbers
  1. Public Function PartialCardnumber(cardnumber as string) as string
  2.     PartialCardnumber = "XXXX XXXX XXXX " & Right$(cardnumber, 4)
  3. End Function
This function would be pasted in to any public code module (those you see when you select the Module tab of your database, or a new module if you don't have any existing public modules). It can be used in your report textbox by placing the following statement in the controlsource property:
Expand|Select|Wrap|Line Numbers
  1. =PartialCardNumber([name of your cardnumber field])
-Stewart

**Edit** Apologies to Linq who replied more or less simultaneously to the same question. Both answers are on similar lines...
Apr 21 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Ships passing in the (cyber) night!

;0)>
Apr 21 '08 #4

P: 10
Thank you for the great ideas. I will try to get them to work.
Apr 22 '08 #5

P: 10
Worked great. Thank you.
Apr 22 '08 #6

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Apr 22 '08 #7

Post your reply

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