Hide Detail

C

Claire

Hi:

My report shows many records for each group but I would only like to see the
first record per group.

I have added a text box to count the records in each group and using the
OnPrint event of the detail section I have tried to specify that the detail
section should not be visible if the count is greater than 1. Unfortunately,
all of the records are still displaying.

My code is as follows:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me!txtRecordCount = 1 Then
Visible = True
Else
Visible = False
End If
End Sub

Can someone (wiser than I) please correct this for me?

Thanks
Claire
 
M

Marshall Barton

Claire said:
My report shows many records for each group but I would only like to see the
first record per group.

I have added a text box to count the records in each group and using the
OnPrint event of the detail section I have tried to specify that the detail
section should not be visible if the count is greater than 1. Unfortunately,
all of the records are still displaying.

My code is as follows:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me!txtRecordCount = 1 Then
Visible = True
Else
Visible = False
End If
End Sub


You should use Option Exxplicit at the top of the module.
Set the option so that all new modules get this
automatically. Your problem is that Visible is a property,
not a variable, and the lack of the Explicit option
suppressed the warning message.

It should be:

Me.Section(0).Visible = ...

Note that it would be more in line with report processing
guidlines to do this in the Format event.
 
C

Claire

Brilliant as usual!!

Thanks Marshall
C.

Claire said:
My report shows many records for each group but I would only like to see the
first record per group.

I have added a text box to count the records in each group and using the
OnPrint event of the detail section I have tried to specify that the detail
section should not be visible if the count is greater than 1. Unfortunately,
all of the records are still displaying.

My code is as follows:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me!txtRecordCount = 1 Then
Visible = True
Else
Visible = False
End If
End Sub


You should use Option Exxplicit at the top of the module.
Set the option so that all new modules get this
automatically. Your problem is that Visible is a property,
not a variable, and the lack of the Explicit option
suppressed the warning message.

It should be:

Me.Section(0).Visible = ...

Note that it would be more in line with report processing
guidlines to do this in the Format event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top