Solved

Name initials in Public Function

Posted on 2013-06-20
5
381 Views
Last Modified: 2013-06-20
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
Comment
Question by:urjudo
  • 3
  • 2
5 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39264739
0
 

Author Comment

by:urjudo
ID: 39264763
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
 

Author Comment

by:urjudo
ID: 39264773
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
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39264775
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
 

Author Closing Comment

by:urjudo
ID: 39264790
Thanks so much for your help capricorn1!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now