Extracting initials from a single string

Jamers2004

New member
Local time
Today, 08:47
Joined
Dec 4, 2017
Messages
4
I am looking to extract initials from a single textbox using Left, mid and other similar functions. The user enters their first, middle initial and last name; assuming spaces and a period after the middle initial. I need to ensure the initials extracted are uppercase, even if the text is entered in lowercase. Any assistance in a code that can accomplish this in VBA for Access would be appreciated. I am able to use the functions individually but am new to coding and am unsure how to string them together correctly.
 
I am looking to extract initials from a single textbox using Left, mid and other similar functions. The user enters their first, middle initial and last name; assuming spaces and a period after the middle initial.

You assume too much. User behaviour is never that consistent.
Some will leave out the spaces, other will double them. Good luck with the period.

Not everyone has a middle initial.

I need to ensure the initials extracted are uppercase, even if the text is entered in lowercase.

UCase() function.
 
I'm assuming because it's what's expected of me. I need to write a code where the user will input their first/MI./last in a textbox. Then, using the left([Name], 1) etc. I need to be able to either look for the spaces and grab the first letters based on that, or some other way. I understand that people will do whatever they want, but in this scenario lets say they don't. This code isn't actually going to be used in production, just as an example. ETA( This isn't the whole code I need to write, just the part I'm stuck on.)
 
' arnelgp
Public Function fnInitials(ByVal strFullName As String)
'
' example:
'
' strInitials = fnInitials("arnel g. puzon")
'
Const SUFFIX As String = "jr./jr/sr./sr/I/II/III/IV/V/VI/VII/VIII/IX/X"
Dim var As Variant
Dim i As Integer
var = Split(strFullName, " ")
For i = 0 To UBound(var)
If InStr(SUFFIX, var(i)) = 0 Then _
fnInitials = fnInitials & UCase(Left(var(i), 1))
Next
End Function
 
There are lots of pitfalls, can't you get them to enter their initials in another text box?
 
There are lots of pitfalls, can't you get them to enter their initials in another text box?

This is homework, there is only one possible scenario and I've been working on this issue for literally 8 hours. We literally just learned about Left, Mid, Right, InStr and Len and this is one tiny portion of my assignment, after a 3 minute tutorial on those functions.
 
' arnelgp
Public Function fnInitials(ByVal strFullName As String)
'
' example:
'
' strInitials = fnInitials("arnel g. puzon")
'
Const SUFFIX As String = "jr./jr/sr./sr/I/II/III/IV/V/VI/VII/VIII/IX/X"
Dim var As Variant
Dim i As Integer
var = Split(strFullName, " ")
For i = 0 To UBound(var)
If InStr(SUFFIX, var(i)) = 0 Then _
fnInitials = fnInitials & UCase(Left(var(i), 1))
Next
End Function

Thank you I will try that! I really appreciate your help. Wish I could send you some cookies.
 
no need for cookies. complete your assignment and we're even.
 

Users who are viewing this thread

Back
Top Bottom