• Pad Field With Spaces? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Pad Field With Spaces? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Author
    Topic
    #449543

    I have the following code that is not working

    If strLastName is a length of 3 I want to pad 1 space between the 3 characters and the strSSN in strVendorNum

    If strLastName is a length of 2 I want to pad 2 spaces between the 2 characters and the strSSN in strVendorNum

    Thanks, John

    If Len(Me.strLastName = 4) Then
        Me.strVendorNum = UCase(Left(Me.strLastName.Text, 4)) _
        & Left(Me.strSSN, 3) & "-" & MID(Me.strSSN, 5, 2) & "-" & Right(Me.strSSN, 4)
    Else
    If Len(Me.strLastName = 3) Then
        Me.strVendorNum = UCase(Left$(Me.strLastName.Text, 4)) & " " _
        & Left(Me.strSSN, 3) & "-" & MID(Me.strSSN, 5, 2) & "-" & Right(Me.strSSN, 4)
    Else
    If Len(Me.strLastName = 2) Then
        Me.strVendorNum = UCase(Left$(Me.strLastName.Text, 4)) & "  " _
        & Left(Me.strSSN, 3) & "-" & MID(Me.strSSN, 5, 2) & "-" & Right(Me.strSSN, 4)
    Else
    If Len(Me.strLastName = 1) Then
        Me.strVendorNum = UCase(Left$(Me.strLastName.Text, 4)) & "   " _
        & Left(Me.strSSN, 3) & "-" & MID(Me.strSSN, 5, 2) & "-" & Right(Me.strSSN, 4)
    End If
    End If
    End If
    End If
    
    Viewing 0 reply threads
    Author
    Replies
    • #1102466

      In what sense is it not working?

      • #1102470

        Last name Bay and social security number 111-22-3333 comes out as:

        Bay111-22-3333

        I want it to be

        Bay 111-22-3333

        • #1102471

          Oh wait – an expression such as

          If Len(Me.strLastName = 4) Then

          makes no sense of course, except if someone’s last name happens to be “4”. It should be

          If Len(Me.strLastName) = 4 Then

          and if strLastName is the active control, you should use

          If Len(Me.strLastName.Text) = 4 Then

          And similarly for the others.

    Viewing 0 reply threads
    Reply To: Pad Field With Spaces? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

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

    Your information: