Hide allbut last four characters of a social security number

G

Guest

I would like to preserve the usual SSN input mask for a social security
number text box, but when returning to the record have only the last four
numbers shown. For instance ***-**-**** on entering the SSN the first time,
and ***-**-1234 when viewing existing records in the same control?
 
D

Damon Heron

You could do this: use the password input mask instead. You could create a
textbox (txtDisplay) and set its visible property to false. Place it
exactly over your SSN textbox. In the current event of the form, put this:

Private Sub Form_Current()
Dim displaystr As String

displaystr = Nz(Me.YourSSNtextboxname, "")
If displaystr <> "" Then
displaystr = "*******" & right(displaystr, 4)
Me.txtDisplay = displaystr
Me.txtDisplay.Visible = True
Else
Me.txtDisplay.Visible = False
End If

End Sub
Since SSNs are all the same length, including the dashes, this will work.
But you would have to build in some error checking for invalid SSNs.

Damon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top