Hiding Social Security Number in form

Samantha

still learning...
Local time
Today, 18:31
Joined
Jul 12, 2012
Messages
182
Hi all,

This should be relatively easy although I seem to have forgotten a lot since the last database I completed. I have looked through several examples online and I am lost. :confused:

On my form frmEmployeeDetails I have a text field that is named SSN for social security numbers. I have used the mask on it so it automatically inputs dashes. I am attempting to hide all but the last four digits of the ssn. This is on the on current event of my form.

Code:
'Hide SSN
Dim strLSSN, strSSN As String
strLSSN = Right(SSN, 4)
strSSN = ("***-**-" & strLSSN)
Me.SSN = strSSN
Any help is greatly appreciated, Thanks!
Samantha
 
Try this
Function MaskedSSN(SSN As String) As String
MaskedSSN = ("***-**-" & Right(SSN, 4))
End Function

on the form load event enter
Me.ssn.value = MaskedSSN(me.ssn.value)

As far as your code is concerned, I think is should work. However, I would dim each variable individually, the first one you have might default to a variant, even though the as string is also on that line. Also, if I am being hyper critical, you are messing with the value of the text box, so fully qualify that. Again the default is value, but I like including it.
 
Privateer,

Sorry for my delay, I got caught up with other issues. You were right I should have Dim'd each individually. Thank you for your help.
For anyone else attempting this you can also insert =("***-**-" & Right([SSN],4)) as the control source for the text box.
 

Users who are viewing this thread

Back
Top Bottom