Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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


    <pre>
    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
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    In what sense is it not working?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Thanks for your help!

Posting Permissions

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