Pergunta

I have a VB report which contains a list of locations. I have this list separated into areas and I need to count the total number of rows per area section. I have a groupHeader which contains my area field, then in the group I list the corresponding entries for that area. Then in the groupFooter I would like to give the total number of entries in the group. How can I do this? I have two fields in my groupFooter

  1. groupCount
  2. groupTotalAmount

-this sums up a value I have in each entry. Any guidance would be appreciated.

Foi útil?

Solução

ewein,

You can get the total records in a group by setting some properties in the designer itself. The simplest example would be using the NorthWind database. You bind your report to the Customers table and want the report to group on countries where each group will contain the cities for that particular country.

From your question I think you are already aware on how to get groups in a report, so I will only talk about getting the record count for each Group. Place a textbox in the GroupFooter. Set its datafield property to "Country" (same as that of groupheader). Now you need to set the following properties for the textbox:

  • SummaryFunction:- Count
  • SummaryGroup:- GroupHeader1 (or the groupheader name you have in your report)
  • SummaryRunning:- Group
  • SummaryType:- SubTotal

You can also get the same results programmatically by using the following code. Please note that "TextBox1" is the textbox used to display the count and is placed in the GroupFooter section:

Private count As Integer = 0

Public Sub GroupHeader1_Format()
    count = 0
End Sub

Public Sub Detail1_Format()
    count += 1
End Sub

Public Sub GroupFooter1_Format()
    TextBox1.Text = count.ToString()
End Sub

I hope this will help you. You may also want to check the ActiveReports blogs where you can find blogs on various areas of interest.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top