Solved

Name initials in Public Function

Posted on 2013-06-20
5
368 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

17 Experts available now in Live!

Get 1:1 Help Now