Solved

Name initials in Public Function

Posted on 2013-06-20
5
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

729 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