• Special Format (XP)

    Author
    Topic
    #420556

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #952624

      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) 10 Then
      MsgBox “Enter either 9 or 10 characters.”, vbExclamation
      Cancel = True
      End If
      End Sub

    Viewing 0 reply threads
    Reply To: Special Format (XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: