I am trying to hide some columns in a subreport based on the value of a field in the main report. The columns are not being hidden. The code seems to be ignored. Any ideas as to why the code is not executing? Here is the code (under the detail - OnFormat event) :
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me!ItemsSubreport.Form!ItemDate.ColumnHidden = True
Me!ItemsSubreport.Form!Qty.ColumnHidden = True
Me!ItemsSubreport.Form!PercOfTotal.ColumnHidden = True
Me!ItemsSubreport.Form!Employee.ColumnHidden = True
Me!ItemsSubform.Form!UnitPrice.ColumnHidden = True
If Me.Category = "Service" Then
Me!ItemsSubreport.Form!ItemDate.ColumnHidden = False
Me!ItemsSubreport.Form!Qty.ColumnHidden = False
Me!ItemsSubreport.Form!UnitPrice.ColumnHidden = False
End If
If Me.Category = "Salary" Then
Me!ItemsSubreport.Form!ItemDate.ColumnHidden = False
Me!ItemsSubreport.Form!PercOfTotal.ColumnHidden = False
Me!ItemsSubreport.Form!Employee.ColumnHidden = False
End If
If Me.Category = "Sales" Then
Me!ItemsSubreport.Form!Qty.ColumnHidden = False
Me!ItemsSubreport.Form!UnitPrice.ColumnHidden = False
End If
End Sub
... (Update) I found out that the code does not fire untill the report prints out. Now I get an error on the first line of code:
Me!ItemsSubreport.Form!ItemDate.ColumnHidden = True
... it seems this is not the right syntax for accessing the fields on the subreport.