Here are 2 routines for consideration. The idea is to have a function that has your "boiler plate text"
and within that text 2 unique strings to act as place holders for your FName and LName.
I have simulated the text which would have to include line breaks (vbCrLf) for proper formatting, and the
test routine has 4 samples of First name and Last name.
I did not try this with a form text box,but the thinking is to call a function with the FName and LName and put the resultant text into the text box. Again not tested at form level, but it may give you some ideas. Some adjustment of line sizes may be needed as you test the routines.
Code:
' ----------------------------------------------------------------
' Procedure Name: testStr
' Purpose: To manipulate a standard text string to incorporate first and last names based on another source (table/query)
' Procedure Kind: Function
' Procedure Access: Public
' Parameter FName (String): FirstName
' Parameter LName (String): LastName
' Return Type: String
' Author: Jack
' Date: 05-Feb-19
'
'using a standard text layout with 2 unique strings ("XK?A" and "XK?Z")
'representing place holders for FName and LName and substituting these
'with "real values" input as parameters to this function.
' ----------------------------------------------------------------
Function testStr(FName As String, LName As String) As String
10 On Error GoTo testStr_Error
Dim str As String, working As String
20 str = "Enclosed please find the above-referenced XK?A XK?Z's fingerprint card and " & vbCrLf _
& "attached Virginia criminal record that has been researched by the FBI " & vbCrLf _
& "and the Virginia State Police in pursuant to Virginia Code §37.2-416 (a), (b), and/or ©. " & vbCrLf _
& "As a result of this information and an additional review done by the " & vbCrLf _
& "DBHDS’ Background Investigations Unit (BIU) the above-referenced XK?A XK?Z " & vbCrLf _
& "ELIGIBLE for employment in a direct consumer care position with your organization."
30 working = str
40 working = Replace(working, "XK?A", FName)
50 working = Replace(working, "XK?Z", LName)
60 testStr = working
70 On Error GoTo 0
80 Exit Function
testStr_Error:
90 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure testStr, line " & Erl & "."
End Function
The test routine
Code:
' ----------------------------------------------------------------
' Procedure Name: testit
' Purpose: Test routine to exercise the TestStr function.
' Procedure Kind: Sub
' Procedure Access: Public
' Author: Jack
' Date: 05-Feb-19
' ----------------------------------------------------------------
Sub testit()
10 On Error GoTo testit_Error
Dim i As Integer
Dim x(3, 1) As String
20 x(0, 0) = "John"
30 x(0, 1) = "Broskovich"
40 x(1, 0) = " Mary Anne"
50 x(1, 1) = "Seashell-Smith "
60 x(2, 0) = "Antonio"
70 x(2, 1) = "Ethan o'lamine"
80 x(3, 0) = "Sue"
90 x(3, 1) = "Hislegzoff"
100 For i = 0 To 3
110 Debug.Print testStr(Trim(x(i, 0)), Trim(x(i, 1)))
120 Debug.Print vbCrLf & " ***************** " & vbCrLf
130 Next i
140 On Error GoTo 0
150 Exit Sub
testit_Error:
160 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure testit, line " & Erl & "."
End Sub
The output
Code:
Enclosed please find the above-referenced John Broskovich's fingerprint card and
attached Virginia criminal record that has been researched by the FBI
and the Virginia State Police in pursuant to Virginia Code §37.2-416 (a), (b), and/or ©.
As a result of this information and an additional review done by the
DBHDS’ Background Investigations Unit (BIU) the above-referenced John Broskovich
ELIGIBLE for employment in a direct consumer care position with your organization.
*****************
Enclosed please find the above-referenced Mary Anne Seashell-Smith's fingerprint card and
attached Virginia criminal record that has been researched by the FBI
and the Virginia State Police in pursuant to Virginia Code §37.2-416 (a), (b), and/or ©.
As a result of this information and an additional review done by the
DBHDS’ Background Investigations Unit (BIU) the above-referenced Mary Anne Seashell-Smith
ELIGIBLE for employment in a direct consumer care position with your organization.
*****************
Enclosed please find the above-referenced Antonio Ethan o'lamine's fingerprint card and
attached Virginia criminal record that has been researched by the FBI
and the Virginia State Police in pursuant to Virginia Code §37.2-416 (a), (b), and/or ©.
As a result of this information and an additional review done by the
DBHDS’ Background Investigations Unit (BIU) the above-referenced Antonio Ethan o'lamine
ELIGIBLE for employment in a direct consumer care position with your organization.
*****************
Enclosed please find the above-referenced Sue Hislegzoff's fingerprint card and
attached Virginia criminal record that has been researched by the FBI
and the Virginia State Police in pursuant to Virginia Code §37.2-416 (a), (b), and/or ©.
As a result of this information and an additional review done by the
DBHDS’ Background Investigations Unit (BIU) the above-referenced Sue Hislegzoff
ELIGIBLE for employment in a direct consumer care position with your organization.
*****************
Hope it's helpful.
Good luck with your project.
Update: I just noticed that I have 2 spaces between XK?A and XK?Z ---that should be reduced to 1 space.