J
jbc
Hi,
I created a function to concatenate names using knowledge
base article acc2000 Sample Function to Format Names
Several Different Ways.
I have 2 questions:
1. I'm using the following in a report and it's not
working. What am I doing wrong?
=NFormat([chrFirst],[chrMiddle],[chrLast],[chrSuffix],
[chrCompany],1)
2. I have a few records that only have a company name and
no first and last name. When I run the function, I only
want the company name to display and not a , or /.
LFM displays: , (It should be blank)
LFMC displays: / XYZ Company (It should be XYZ Company)
*****
Public Function NFormat(chrFirst As Variant, chrMiddle As
Variant, chrLast As _
Variant, chrSuffix As Variant, chrCompany As Variant,
varStyle As Variant)
On Error GoTo Err_NFormat
Dim strNewName As String
Select Case varStyle
Case "0", "FML"
strNewName = chrFirst & " " & (chrMiddle + " ") &
chrLast & (", " + chrSuffix)
Case "1", "LFM"
strNewName = chrLast & (", " + chrSuffix) & (", "
& chrFirst) & (" " + chrMiddle)
Case "2", "LFMC"
strNewName = chrLast & (", " + chrSuffix) & (", "
+ chrFirst) & (" " + chrMiddle) & (" / " + chrCompany)
Case Else
strNewName = ""
End Select
NFormat = Trim(strNewName)
Exit Function
Err_NFormat:
NFormat = "#Error"
End Function
Thank you.
jbc
I created a function to concatenate names using knowledge
base article acc2000 Sample Function to Format Names
Several Different Ways.
I have 2 questions:
1. I'm using the following in a report and it's not
working. What am I doing wrong?
=NFormat([chrFirst],[chrMiddle],[chrLast],[chrSuffix],
[chrCompany],1)
2. I have a few records that only have a company name and
no first and last name. When I run the function, I only
want the company name to display and not a , or /.
LFM displays: , (It should be blank)
LFMC displays: / XYZ Company (It should be XYZ Company)
*****
Public Function NFormat(chrFirst As Variant, chrMiddle As
Variant, chrLast As _
Variant, chrSuffix As Variant, chrCompany As Variant,
varStyle As Variant)
On Error GoTo Err_NFormat
Dim strNewName As String
Select Case varStyle
Case "0", "FML"
strNewName = chrFirst & " " & (chrMiddle + " ") &
chrLast & (", " + chrSuffix)
Case "1", "LFM"
strNewName = chrLast & (", " + chrSuffix) & (", "
& chrFirst) & (" " + chrMiddle)
Case "2", "LFMC"
strNewName = chrLast & (", " + chrSuffix) & (", "
+ chrFirst) & (" " + chrMiddle) & (" / " + chrCompany)
Case Else
strNewName = ""
End Select
NFormat = Trim(strNewName)
Exit Function
Err_NFormat:
NFormat = "#Error"
End Function
Thank you.
jbc