• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

Name initials in Public Function

Hi experts,
I just got the answer from the previous ticket, capricorn1 show me the example, now I try to edit, but it seems not working.  My original question was:

Jane Doe   --   would like show j,d

Jane A. Doe  -- would like to show j,a,d

Jane B. Doe-Smith   -- would like to show j,b,D-S

John C. Smith-Jones, JR  -- would like to show j,c,s-m,jr

John Smith, JR  -- would like to show j,s,jr

now I want to do is

Jane Doe   --   would like show j. d

Jane A. Doe  -- would like to show j. a. d

Jane B. Doe-Smith   -- would like to show j. b. D-S

John C. Smith-Jones, JR  -- would like to show j. c. s-m, jr.

John Smith, JR  -- would like to show j. s, jr.

John Jones, III  - would like to show j. j, III.


thanks
db-Q-28163004.mdb
0
urjudo
Asked:
urjudo
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
0
 
urjudoAuthor Commented:
Hi capricorn1, how can I put a space after the period?  I tried this but the first record has two period. also need a space before the JR or III something like

John C. Smith-Jones, JR  -- would like to show j. c. s-m, jr.
John Jones, III  - would like to show j. j, III.
db-Q-28163004-Rev.mdb
0
 
urjudoAuthor Commented:
I got the space for the JR question, but the fisrt record that doesn'r have middle initial still showing J..D instead J. D
0
 
Rey Obrero (Capricorn1)Commented:
use this



Function fGetInitials(strName As String) As String
Dim varName() As String, j As Integer, strInit As String, xName() As String
If strName & "" <> "" Then
     varName = Split(strName, " ")
     
     For j = 0 To UBound(varName)
          If j > 2 Then
               strInit = strInit & ", " & varName(3) & "."
               Exit For
          End If
          xName = Split(varName(j), "-")
          If UBound(xName) > 0 Then
               strInit = strInit & ". " & Left(xName(0), 1) & "-" & Left(xName(1), 1)
               Else
               strInit = strInit + ". " + Left(varName(j), 1)
          End If
   
     Next
     fGetInitials = Replace(Mid(strInit, 2), ". .", ". ")
End If

End Function
db-Q-28163004-Rev.mdb
0
 
urjudoAuthor Commented:
Thanks so much for your help capricorn1!!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now