Setting up to show only last 4 digits on ss# OR credit card field / using input mask?

pam0566

Registered User.
Local time
Today, 10:47
Joined
Jun 6, 2008
Messages
132
I have a form that gathers employee social security numbers. I am using access 2007. Is there a way to [after info typed in] only display the last for digits of the SS#? so 444-44-4444 would show as ***-**-4444? I have done a search but not finding anything. I could have sworn i saw this somewhere before, but cant find it.
 
I came up with this workaround. In Design View:

  1. Select and Copy and your SSN textbox
  2. Paste this copy on your form and name it DisplaySSN.
  3. After you enter the name, move down one box to Control Source and set this to nothing; this will be an unbound textbox.
  4. Now position DisplaySSN so that it's directly on top of the SSN
Now use this code, replacing SSN with the actual name of your textbox that holds the social security number:

Code:
Private Sub Form_Current()
 If Not Me.NewRecord Then
   SSN.Visible = False
   DisplaySSN.Visible = True
   Me.DisplaySSN = "***-**-" & Right(Me.SSN, 4)
 Else
   SSN.Visible = True
   DisplaySSN.Visible = False
 End If
End Sub

Now the SSN will remain visible until yousave the record and move off of it. When you return to the record, you'll see the SSN displayed as ***-**-1234.
 
where do i insert the code? on what event line?
 
never mind... on the form current ()-- works great.. thanks so much!!!!!!
 
I have a question. will this work as well to cover a combo box? say if a new record show the combo, if not a new record show text box? i know shouldnt matter, but i am importing from another data base and cant get a city field to show.. thought this mgiht be a quick fix.
 

Users who are viewing this thread

Back
Top Bottom