Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Nov 2004
    Wilmington, North Carolina, USA
    Thanked 0 Times in 0 Posts

    Special Format (XP)

    I guess I just need some suggestions...I use a 10-digit format for SSNs, (my PK). I need my format to force 10 digits, but allow an 'N' as the first character. If the N isn't put in upon data entry, and the SSN field is left at 9 characters, I want Access to automatically add a '0' to the front of my string. Any ideas?
    "If you spend more on coffee than on IT security, then you will be hacked. What's more, you deserve to be hacked." -Richard Clarke

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Special Format (XP)

    You can test the input in the Before Update and After Update events of the text box bound to the SSN field:

    Private Sub SSN_AfterUpdate()
    If Len(Me.SSN) = 9 Then
    Me.SSN = "0" & Me.SSN
    End If
    End Sub

    Private Sub SSN_BeforeUpdate(Cancel As Integer)
    If Len(Me.SSN) < 9 Or Len(Me.SSN) > 10 Then
    MsgBox "Enter either 9 or 10 characters.", vbExclamation
    Cancel = True
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts