I wrote some code in VBA that takes fields from a query and concatenates their values to create one string that will be used in a text box control for a report. If a field is empty, it is not to be included in the report.
The code was written in the OnCurrent event of the report. I declared a String variable, set it to include the concatenated value, and then set the control source to equal the string variable.
When I view the report in print preview, it does not include the information. The code I had written is similar to this:
Dim strSource As String
strSource = IIf(IsNull([field1]), "", [field1] & ", ") & _
IIf(IsNull([field2]), "", [field2] & ", ") & _
IIf(IsNull([field3]), "", [field3] & ", ") & _
IIf(IsNull([field4]), "", [field4] & ", ") & _
IIf(IsNull([field5]), "", [field5] & ", ") & _
IIf(IsNull([field6]), "", [field6] & ", ") & _
IIf(IsNull([field7]), "", [field7] & ", ") & _
IIf(IsNull([field8]), "", [field8])
Me.TextBox.ControlSource = strSource
Where did I make my error?