replace text with XXXX for protection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fdespoux
    New Member
    • Mar 2008
    • 10

    replace text with XXXX for protection

    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
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Place an Unbound textbox on your report and as itsControl source use

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

    Where CCN is your field holding the credit card number.

    Welcome to bytes!

    Linq ;0)>

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      Originally posted by fdespoux
      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:
      Code:
      ="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:
      [code=vb]Public Function PartialCardnumb er(cardnumber as string) as string
      PartialCardnumb er = "XXXX XXXX XXXX " & Right$(cardnumb er, 4)
      End Function[/code]
      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:
      Code:
      =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...
      Last edited by Stewart Ross; Apr 21 '08, 07:29 PM. Reason: added comment

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Ships passing in the (cyber) night!

        ;0)>

        Comment

        • fdespoux
          New Member
          • Mar 2008
          • 10

          #5
          Thank you for the great ideas. I will try to get them to work.

          Comment

          • fdespoux
            New Member
            • Mar 2008
            • 10

            #6
            Worked great. Thank you.

            Comment

            • missinglinq
              Recognized Expert Specialist
              • Nov 2006
              • 3533

              #7
              Glad we could help!

              Linq ;0)>

              Comment

              Working...