Hi all,
I have a report that looks at a series of unbound check boxes on my form. The code in my report looks to see which boxes are checked, assigns a text string and then Concatenates those strings in a text box, depending on which boxes are checked, it also looks up some verbiage in a table and concatenates that into another text field.
Code:
Private Sub Report_Load()
Dim SU_CoC As String
Dim T_CoC As String
Dim SU_MatCoC As String
Dim T_MatCoC As String
Dim SU_83 As String
Dim T_83 As String
Dim SU_97 As String
Dim T_97 As String
Dim SU_286 As String
Dim T_286 As String
Dim PSIVal1 As String
Dim Sub_Text As String
Dim Verb1_Text As String
PSIVal1 = Nz(Forms![frmCert]![txt97_PSIG], "")
If [Forms]![frmCert].ck_COC = True Then
SU_CoC = "Certificate of Conformance"
T_CoC = (DLookup("[Verbiage]", "tblCerts", "[CertNumb] = 'CoC'") & Chr(13) & Chr(10))
Else
SU_CoC = ""
T_CoC = ""
End If
If [Forms]![frmCert].ck_MCOC = True Then
SU_MatCoC = "Material Certification"
T_MatCoC = (DLookup("[Verbiage]", "tblCerts", "[CertNumb] = 'MatCert'") & Chr(13) & Chr(10))
Else
SU_MatCoC = ""
T_MatCoC = ""
End If
If [Forms]![frmCert].ck_83 = True Then
SU_83 = "S-83"
T_83 = (DLookup("[Verbiage]", "tblCerts", "[CertNumb] = 'S-83'") & Chr(13) & Chr(10))
Else
SU_83 = ""
T_83 = ""
End If
If [Forms]![frmCert].ck_97 = True Then
SU_97 = "S-97"
T_97 = (Replace(DLookup("[Verbiage]", "tblCerts", "[CertNumb] = 'S-97'"), "PSIVALUE1", PSIVal1) & Chr(13) & Chr(10))
Else
SU_97 = ""
T_97 = ""
End If
If [Forms]![frmCert].ck_286 = True Then
SU_286 = "S-286"
T_286 = (DLookup("[Verbiage]", "tblCerts", "[CertNumb] = 'S-286'") & Chr(13) & Chr(10))
Else
SU_286 = ""
T_286 = ""
End If
Sub_Text = SU_CoC & (", " + SU_MatCoC) & (", " + SU_83) & (", " + SU_97) & (", " + SU_286)
Me.txtSubject = Sub_Text
Verb1_Text = T_CoC & T_MatCoC & T_83 & T_97 & T_286
Me.txtVerb1 = Verb1_Text
End Sub
So my issue is I am attempting to suppress null values by using "+" instead of "&", so that I do not have a bunch of extra commas in my string, its not working as expected. If I only have the CoC box checked, I get "Certificate of Certification, , , , , , " as my field output.
Another issue I am running into is adding carriage returns in my Verbiage field. How I have this set up, in my tblCerts, I have several different tests listed and verbiage that describes the outcome of those tests. I would like there to be a return and empty line after each set of verbiage so similar to this:
Test 69 was executed as expected.
Test 125 was executed as expected.
I have tried a few different alterations of the code to attempt to get this to work, including adding the & Chr(13) & Chr(10) string at the bottom where I define Verb1_Text, I have attempted to replace the & Chr(13) & Chr(10) with vbCrLf but neither produce a carriage return.
Any ideas?