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
groupCount
groupTotalAmount
-this sums up a value I have in each entry. Any guidance would be appreciated.
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.
Related
My goal is to create an access database form with ordering multiple item at a time. But for this phase my end goal is to find the total cost by multiplying price per unit*quantity. Through my working out i got stucked by the problem of on change event. Basically, whenever i change a the id in the combo box it changes in all the textbox that i programmed.
Here is the scenario:
In this case the price per unit stays 1000 for all of the stock ID, whereas, when i have stock id of 2 i want the price to be 0 and so on.
This is how i programmed the get price per unit value
Private Sub StockIDCombo_Change()
Me.PricePerUnit.Value = Me.StockIDCombo.Column(3)
End Sub
Note that the form is continuous.
Have an additional field in the table to hold the calculation, and bind your textbox to this field.
Is your PricePerUnit control unbound? It should be bounded to some table field as other fields (StockID, Quantity).
I have an unbound text box [txt_AmendmentOF] on a form to count the total number of Amendments a specific record has in the database. So the user knows which amendment they are on. Just a simple you are on Amendment 3 out of 8. i have this calculation i am using in the Control Source field of the text box [txt_AmendmentOF]:
=IIf(IsNull([txt_Amendment]),0,Count([MIPR_Number]))
there is a Field on my table called [Amendment] its text box on the form is called [txt_Amendment]. I have the calculation return a zero in [txt_AmendmentOF] if [txt_Amendment] is null. I need it to count the record number [MIPR_Number] that are the same and return the total number of Amendments count in the [txt_AmendmentOF] text box. on my table i have private key field called [ID] it is an autonumber format. The problem with the code above is it is counting all the fields that have a [MIPR_Number] and returning the total row count of that. i am not an expert here so any help would be greatly appreciated.
Update to post..
I have also tried this and got an error in the text box
=IIf(IsNull([txt_Amendment]),0,Count([MIPR_Number]=[txt_MIPR_Number]))
Counting by a condition is one of the basic dataabase tasks. To get answers from a db, you have to query the database (and that is done by createing a query).
To count same[MIPR_Number]you have to group the data (a group contains same numbers), then count.
SELECT COUNT(id) as CountOfSameNr, [MIPR_Number] FROM Table GROUP BY [MIPR_Number]
Store this query as e.g CountMIPRNumber.
Now you have two options:
Use a Dlookup to get one value
=IIf(IsNull([txt_Amendment]),0,Dlookup("CountOfSameNr","CountMIPRNumber","[MIPR_Number] = " & [MIPR_Number]))
or add the query to form recordsource (join on [MIPR_Number], "SELECT * FROM TABLE" is forms query)
SELECT CountMIPRNumber.CountOfSameNr, TABLE.* FROM TABLE LEFT JOIN CountMIPRNumber ON TABLE.[MIPR_Number] = CountMIPRNumber.[MIPR_Number]
and reference the count field
=IIf(IsNull([txt_Amendment]),0,[CountOfSameNr])
Very new to Pentaho Reporting,
I have a query grabbing columns categories, quantity, and gross. It returns about 200 rows.
Without changing the query, is there a way for the report to display the aggregates for each category (I have category as a group)? For example, All you can eat should only display a sum of the Amount and GrossValue columns.
Same for dessert (notice there are two group headers - why?)
You just need to get used to with pentaho report designer.
Refer information given at the end of this page simple report.
You can add one parameter in group footer and set its properties.
They provides properties like aggregation-type, which can be set as Sum or count and then it will show at the end of each group with sum or count of the rows as per the type you specified.
I have a Access 2010 report with two groups I set up in design. The first group has person data (name, dob, current address, customer points, date customer last placed a order). The second group has for the current person, all of their orders. The form that calls this report has a sort by option. They can sort by the name ascending or decending, the last date they ordered something asc/desc, and how many customer points they have asc/desc. All of these sort options should work on the data in the first/primary report group. Is there any way to call this report and set the orderby in VBA when the report already contains groups? I am passing in args from the form and trying on the load
Me.OrderBy = ArgIn(2)
Me.OrderByOn = True
I have also tried this in the open event. The report opens but ignores the sorting/order by.
Thanks
There are two routes you can go rather than passing arguments:
Create 3 exact same reports but with different sorting (within report design on group, you can sort the underlying items) and have a form trigger button with a drop down or list menu for user to select specific report ordering and then call the particular report.
In VBA, create a dynamic, user-defined querydef (Set qrydef = db.CreateQueryDef("[QUERY NAME]", strSQL) that is called by a form trigger button on a particular SQL statement out of three for each ORDER BY type (last name, date, points). Set the querydef to the report's recordsource.
The best dynamic way to do this is to use .SortOrder and .ControlSource:
Private Sub Report_Open(Cancel As Integer)
' Set SortOrder property to Ascending order (SortOrder = False)
Me.GroupLevel(0).SortOrder = blSortOrder
Me.GroupLevel(0).ControlSource = strSortBy
End Sub
.ControlSource is the field name of your reports table/query to be sorted. The filter hierarchy is addressed like Me.GroupLevel(0), Me.GroupLevel(1), Me.GroupLevel(2), etc..
Pass in this data via Me.OpenArgs.
Me.GroupLevel(0).SortOrder = Split(Me.OpenArgs, "|")(0)
Me.GroupLevel(0).ControlSource = Split(Me.OpenArgs, "|")(1)
Call the report like:
DoCmd.OpenReport "ReportName", acViewPreview, , , acWindowNormal, strSortBy & "|" & blSortOrder
...and make sure the sorted field is unique in its table, if you use grouping. (Notice that Access turns sorting into grouping when you add a header).
I'd like to count a text-string in every page on a report and print out the count of the strings in the page-footer.
Searching for a string in a text field is straight forward, counting the findings within the text-field too, but how is it possible to sum the findings in a integer variable per report-page when it has several entries?
i.e. I´ve got a report-page like this where each new line is a new record.
Here the first report-page:
aaaaaaF
aaaaaFF
ffaaaaaaaaa
FaaaaaFF
Now the page-footer:
There are 4 records. The letter "F" has been found 6 times on this report page.
Now the second report-page:
aaaFaaF
aaaaaF
fFaaaaaaaaa
FaaaFaFF
FFaaaaFa
page-footer:
There are 5 records. The letter "F" has been found 10 times on this report page.
I'd be happy if smdy has an advice for me.
Thanks!
First step is to figure out how many occurances of "f" occur in each record. Which you can do using
= Len([myField]) - Len(Replace([myField],"f",""))
Now for the total occurances in that page you use the Sum function in a text box in the report footer section.
= Sum( ... )
= Sum(Len([myField]) - Len(Replace([myField],"f",""))) ' if report based on a table
= Sum([myCalculatedField]) ' if you use the occurance count formula in the query instead
If you need to total across the page there is a link detailing how to go about it here (you'll have to scroll down a bit)
http://office.microsoft.com/en-us/access-help/summing-in-reports-HA001122444.aspx
You haven't shown any of the expressions that you are using but, essentially, in the Report Footer you would include a textbox which uses your aggregate function:
=COUNT([SomeField]) 'or
=SUM(iif(some condition, 1, 0))
where SomeField is a field in the detail section, or some condition refers to this field.
That is, you need to SUM (or COUNT) across the whole report by referring to field(s) in the details section. You do not do this by attempting to refer to the subtotals that you have in the page-footers - this won't work.