I have a report where I'm using code to hide a label if the corresponding field is empty. This is the code:
I've added a line for each of the necessary fields. This works but what I'd like to be able to do is have a list I can add the fields to and then loop through the list. Something like this:Code:Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Me.[myfield1].Visible = Not IsNull(Me.[myfield1]) Me.[myfield2].Visible = Not IsNull(Me.[myfield2]) Me.[myfield3].Visible = Not IsNull(Me.[myfield3]) Me.[myfield4].Visible = Not IsNull(Me.[myfield4]) End Sub
I'm just not sure what code I need. If someone could help me out, I'd be very greatful.Code:Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Dim strFieldNames as String strFieldNames = myfield1 myfield2 myfield3 myfield4 For each item in strFieldNames Me.[item].Visible = Not IsNull(Me.[item]) End Sub


Reply With Quote

