MissaLissa
New Member
- Joined
- Jul 2, 2013
- Messages
- 26
Hi Guru's
I'm using vbProperCase in a sub AfterUpdate. However, the vbProperCase does not take into consideration last names that have a hyphen or apostrophe. So, I found a function to solve the issue, but I'm not sure how to implement it. Can someone please walk me through this? Much appreciated.
current code:
Need to add the following function:
I'm using vbProperCase in a sub AfterUpdate. However, the vbProperCase does not take into consideration last names that have a hyphen or apostrophe. So, I found a function to solve the issue, but I'm not sure how to implement it. Can someone please walk me through this? Much appreciated.
current code:
Code:
Private Sub Applicant2_Last_Name_AfterUpdate()
Me.Applicant2_Last_Name = StrConv(Me.Applicant2_Last_Name, vbProperCase)
End Sub
Need to add the following function:
Code:
Public Function fProperCase(ByVal vName As String)
Dim vReturn
Dim vLeft
Dim vRight
Dim lHyphen As Long
Dim lApostrophe As Long
vReturn = Null
lHyphen = Nz(InStr(1, vName, "-", vbBinaryCompare), 0)
lApostrophe = Nz(InStr(1, vName, "'", vbBinaryCompare), 0)
If Len(vName) Then
If lHyphen Then
vLeft = Mid(vName, 1, lHyphen - 1)
vRight = Mid(vName, lHyphen + 1)
vReturn = StrConv(vLeft, Conversion:=vbProperCase) & "-" & StrConv(vRight, Conversion:=vbProperCase)
Else
If lApostrophe Then
vLeft = Mid(vName, 1, lApostrophe - 1)
vRight = Mid(vName, lApostrophe + 1)
vReturn = StrConv(vLeft, Conversion:=vbProperCase) & "'" & StrConv(vRight, Conversion:=vbProperCase)
Else
vReturn = StrConv(vName, Conversion:=vbProperCase)
End If
End If
End If
fProperCase = vReturn
End Function
Last edited: