You can use conditions in the Format event to control when the report's Detail section is shown.

To add code to hide the detail section
- Double-click the detail section of the report to create an event-handling method for the Detail Format event.
- Add code to the handler to hide the detail section if the product is discontinued.
The following example shows what the code for the method looks like. This code assumes that your report has the following fields:
- txtReorderLevel (numeric)
- txtDiscontinued (Boolean)
To write the code in Visual Basic.NET
| Visual Basic.NET code. Paste INSIDE the Detail Format event. | Copy Code |
|---|---|
If Me.txtReorderLevel.Value = 0 And Me.txtDiscontinued.Value = False Then
Me.Detail1.Visible = True
Me.txtDiscontinued.Text = ""
Me.txtReorderLevel.Text = "Need to Reorder"
Me.txtReorderLevel.ForeColor = System.Drawing.Color.DarkRed
Else
Me.Detail.Visible = False
End If | |
| C# code. Paste INSIDE the Detail Format event. | Copy Code |
|---|---|
if(txtReorderLevel.Value == 0 && txtDiscontinued.Text == False)
{
this.detail.Visible = true;
this.txtDiscontinued.Text = "";
this.txtReorderLevel.Text = "Need to Reorder";
this.txtReorderLevel.ForeColor = System.Drawing.Color.DarkRed;
}
else
{
this.detail.Visible = False;
} | |
Create Green Bar Reports
Walkthroughs
Basic Data Bound Reports
Hide All