Microsoft Access reporting -GROUPBY - ms-access

I'm trying to build a report in microsoft access. I have a company name called "FRPP" and I need to display number of employees, etc. The issue is, I have many subdivisions of FRPP that are in different locations. So I have:
FRPP - ASIA
FRPP - EUROPE
FRPP - AFRICA
FRPP - SOUTH AMERICA
Now, what I'm trying to do is GROUPBY by 'FRPP'. How would I do that? So I only have one instance of FRPP with a Employees: SUM(employees).

Unfortunately I normally do all this sort of thing in my SQL Server backend, so not 100% sure it will work in Access, but try something like
SELECT SUM(Employees), LEFT(CompanyName,4) AS MainCompany FROM Company GROUP BY LEFT(CompanyName,4)
If company names are all different lengths you will have to work out a way to calculate how much should be in the Left function (Use Instr to get the index of a space?)

In the Report Design Tools, on the Design tab, there is a button for Group & Sort. Click that, and then click on the Add A Group button that appears on the bottom of your form. Group by your Unique ID and add that to the Header section of the form. Add each field you want into the Detail section, and change the formulas to
=Sum([YourFieldName])
Change YourFieldName above to whatever your actual field name is.

Related

How to make sure that MS Access displays the correct subreport data of the current record?

I have a payslip main report with 3 subreports, all are linked through the employee's serialNumber:
rptPayslipPay -for displaying regular pay
rptPSDeds - for displaying deductions
rptPayslipOpay - for displaying supplementary payments. This
subreport is only showed for few selected employees.
I was able to show the total amounts of the 3 subreports on my main report's page footer. Since my last subreport rptPayslipOpay, may or may not have any data, I am displaying it in a text box named [txtOpay] like this:
=IIf([rptPayslipOPay].[Report].[HasData],[rptPayslipOPay].[Report]![sumOpay],"")
My problem is,the value of [txtOpay] shows even if the page has moved on to another employee, thus displaying the previous employee's supplementary payments to the next employee.
Is there a way to prevent this from happening?
Thank you very much.
You might be able to get it to work by fiddling around with the subreports, but assuming a 1:1 relationship between top-level report and subreport, and assuming serialNumber is a string; instead of your IIf statement, you might consider trying something along the lines of:
=DLookup("sumOpay", [rptPayslipOPay].Report.RecordSource, "serialNumber='" & [serialNumber] & "'")
I'm not sure exactly how your objects are named, but I think this should be close to what you're looking for.
By your description, it sounds like "sumOpay" might be a calculated field in the rptPayslipOPay report. If so, you can use:
=DSum("<field containing data to sum>", [rptPayslipOPay].Report.RecordSource, "serialNumber='" & [serialNumber] & "'")
Granted, these will run more slowly, but this might be an easier way to get it to work.
Another option is to left-join rptPayslipOPay's data from in your top-level query, and sum it.

Crystal Reports 2013: Inconsistent Page Header Formula Fields

Background
I am using Crystal Reports 2013 SP1 to create a customized invoicing report for a client. This client requires invoicing to be combined onto one 'consolidated invoice' for each of their products. Client invoices are typically created at each originating location of the work for each version of each product. As you might imagine, a client with many products can receive many invoices! So, in order to achieve this consolidation, I created two Formulas:
ProdNameNoDig - A string field that removes the word 'Digital' so that versions are grouped together (i.e. both 'traditional' version charges and 'digital' version charges are included on the same 'consolidated invoice').
InvLocation - A string field that indicates a region so that multiple originating locations can be grouped together (e.g. invoices normally be split by City1, City2, City3, but will now all be included as Region1 on the same 'consolidated invoice').
I then grouped the data by ProdNameNoDig, then InvLocation, then InvoiceNumber, then LineItem. Here is a snapshot of the Design View with the Group Expert open:
When I view the reports, they are grouped properly- all of the invoices for a product's versions are grouped by region, and all of the details display as I intend.
The Problem
Here is the issue occurring when the report is created:
Product A, Region 1- Everything looks fine.
Product A, Region 2- Everything looks fine.
Product B, Region 1- Green circled areas of the report have the correct data. Red circled areas of the report use the ProdNameNoDig and InvLocation of Product A, Region 2
Product B, Region 2 - Everything looks fine.
Product C, Region 1- Green circled areas of the report have the correct data. Red circled areas of the report use the ProdNameNoDig and InvLocation of Product B, Region 2
This continues through the entire report
After the final product's last region, a blank (includes only the Page Header and Page Footer) page is created with the ProdNameNoDig and InvLocation of the final product's last region.
The Page Header is not properly displaying ProdNameNoDig or InvLocation (circled in Red) after a change in Group 1 (ProdNameNoDig). The SAME FIELD shown twice elsewhere on the report (circled in green) displays the correct information for the group being reported. The Page Header displays the information for the previous group! Why is a reference to the same Formula Field displaying different information in different parts of the report?
What you can do is create a section B on your location group, move everything from A to B and copy the info on you PH to A. Then suppress you PH when pagenumber <> 1 and same for section A, but when pagenumber = 1. In that way your info will be changing once your group change.
To the extent I understand your problem... whenever there is new Group you are facing this issue where last group2 and group1 are displayed in page header.
Without knowing how your data is getting printed as how group2 extends and where group1 starts.. my assumption is group1 is not starting when a new page starts and hence it still holds the previous value of group2 and group1...
one wayout would be instead of page header create one more group section of Group1 and display there your data.
Coming to the green area where data is correctly displayed.
One is in group2 which holds the group1 data as group2 comes after group1 and displayed correct.
second is page footer which comes after the group1 changes its values and correct data.
Let me know if it is not clear

Replacement for DLookup to autofill a form with multple values in Access

I currently have a form which contains a seperate combo box that is related to each table I have created.
These include:
- Business Process Area
- Title
- ReportDescription
- ProcessChain
- MultiProvider
- InfoProvider
I'm having multiple issues, but for now I'll just narrow it down to the one.
I want the form to autofill if you select a lower combo box, so for example if you select a Report Description it will fill Title and Business Process Area. I am using DLookup to do this currently and this is working fine. The issue occurs further down the form.
There are many-to-many relationships between ReportDescription and ProcessChain as well as between ProcessChain and MultiProvider. So currently you can select a MultiProvider, and it will just select the first ProcessChain and keep filling the form from there.
My Current DLookup code on my bottom combo box is:
If IsNull(cmbMultiProvider) Then
cmbMultiProvider = DLookup("MultiProviderID", "MultiProvider", "MultiProviderID =" & Me.cmbInfoProvider.Column(2))
End If
If IsNull(cmbProcessChain) Then
cmbProcessChain = DLookup("ProcessChainID", "ProcessChainMultiProvider", "ProcessChainID =" & Me.cmbMultiProvider.Column(2))
End If
If IsNull(cmbReportDesc) Then
cmbReportDesc = DLookup("ReportID", "ReportDescription", "ReportID =" & Me.cmbProcessChain.Column(2))
End If
And so fourth.
So I would like to replace these DLookup statements with something that will stop at the combo box if the selection below relates to multiple of the field above, as in if a MultiProvider selected in a combo box relates to many Process Chains then the combo box will drop down and only contain the related fields.
Thank you in advance for any help.
So you're going "backwards" up the cascading combos? That is, in most cases you would select these items in descending order, but you're moving up in Ascending order. For example, if you wanted to drill down to an automobile, you generally first select the Year, then the Make, then the Model, etc etc.
Instead, you want to select the Make, and have the Model auto-populate (assuming there is only one Make for that specific Model), and then have the Year left blank (since there could be several Years for a Make and Model).
If so, can you tell us more about your data structure? How are Report Description, Process Chain and MultiProvider related in your tables?

Populating data in multiple cascading dropdown boxes in Access 2007

I've been assigned the task to design a temporary customer tracking system in MS Access 2007 (sheeeesh!). The tables and relationships have all been setup successfully. But I'm running into a minor problem while trying to design the data entry form for one table... Here's a bit of explanation first.
The screen contains 3 dropdown boxes (apart from other fields).
1st dropdown
The first dropdown (cboMarket) represents the Market lets users select between 2 options:
Domestic
International
Since the first dropdown contains only 2 items I didn't bother making a table for it. I added them as pre-defined list items.
2nd dropdown
Once the user makes a selection in this one, the second dropdown (cboLeadCategory) loads up a list of Lead Categories, namely, Fairs & Exhibitions, Agents, Press Ads, Online Ads etc. Different sets of lead categories are utilized for the 2 markets. Hence this box is dependent on the 1st one.
Structure of the bound table, named Lead_Cateogries for the 2nd combo is:
ID Autonumber
Lead_Type TEXT <- actually a list that takes up Domestic or International
Lead_Category_Name TEXT
3rd dropdown
And based on the choice of category in the 2nd one, the third one (cboLeadSource) is supposed to display a pre-defined set of lead sources belonging to the particular category.
Table is named Lead_Sources and the structure is:
ID Autonumber
Lead_Category NUMBER <- related to ID of Lead Categories table
Lead_Source TEXT
When I make the selection in the 1st dropdown, the AfterUpdate event of the combo is called, which instructs the 2nd dropdown to load contents:
Private Sub cboMarket_AfterUpdate()
Me![cboLead_Category].Requery
End Sub
The Row Source of the 2nd combo contains a query:
SELECT Lead_Categories.ID, Lead_Categories.Lead_Category_Name
FROM Lead_Categories
WHERE Lead_Categories.Lead_Type=[cboMarket]
ORDER BY Lead_Categories.Lead_Category_Name;
The AfterUpdate event of 2nd combo is:
Private Sub cboLeadCategory_AfterUpdate()
Me![cboLeadSource].Requery
End Sub
The Row Source of 3rd combo contains:
SELECT Leads_Sources.ID, Leads_Sources.Lead_Source
FROM Leads_Sources
WHERE [Lead_Sources].[Lead_Category]=[Lead_Categories].[ID]
ORDER BY Leads_Sources.Lead_Source;
Problem
When I select Market type from cboMarket, the 2nd combo cboLeadCategory loads up the appropriate Categories without a hitch.
But when I select a particular Category from it, instead of the 3rd combo loading the lead source names, a modal dialog is displayed asking me to Enter a Parameter.
alt text http://img163.imageshack.us/img163/184/enterparamprompt.png
When I enter anything into this prompt (valid or invalid data), I get yet another prompt:
alt text http://img52.imageshack.us/img52/8065/enterparamprompt2.png
Why is this happening? Why isn't the 3rd box loading the source names as desired. Can any one please shed some light on where I am going wrong?
Thanks,
m^e
===================================================
UPDATE
I found a glitch in the query for the 3rd combo.. It wasn't matching up with the value of the second combo. I fixed it and now the query stands at:
SELECT Leads_Sources.ID, Leads_Sources.Lead_Source
FROM Leads_Sources
WHERE (((Leads_Sources.Lead_Category)=[cboLead_Category]))
ORDER BY Leads_Sources.Lead_Source;
Those nasty Enter Param prompts are GONE!!! However, the 3rd combo still stubbornly refuses to load any values. Any ideas?
Never mind. Found the fix. The BoundColumn property of the second combo wasn't set to the correct column. Hence the selection values in it were incorrect and the 3rd combo wasn't able to refer to the linked table properly (with the correct index).
Job done :)
Thanks to all who may have taken time out to review the problem.

SSRS- Bar Chart with single bar needs to display Percentage data

I have a requirement to show percentages in bar chart on a single bar using SSRS. For example, I want to show a employees by Age in a percentage in an SSRS report.
1.How many % employees between age 20 and 30?
2.How many % employees between age 30 and 40?
3.How many % employees between age 40 and 50?
All this on a chart which has only single bar chart in percentage?
Is it possible?
Thanks
Not sure I'm really understanding the question ("a chart which has only single bar chart in percentage"?), and I realise it's an old one, but I just came here with what I think is the same problem, and wanted to offer the solution I've come up with.
As far as I understand it, you have a bar chart which shows employees grouped by age. Age bracket along the X axis, number of employees (which I'll presume is calculated by something like "COUNT(Fields!EmployeeID.value)") up the Y axis. You want to see the percentage of employees which fall into each bracket.
What I've done is go into the chart properties, "Data" and select the "Values" entry for "Employees" (or similar). Then, hit Edit and add point labels, with a data label such as:
=COUNT(Fields!EmployeeID.value) / COUNT(Fields!EmployeeID.value, "Employees")
Where "Employees" is the name of your data set.
This is dividing the value of the current data group (from the "Values" tab) by same value but taken over the whole dataset.
Enter a format code of something like "#0%", et voila!
It achieved what I was after, and I hope it can help others with the same question.
You can easily do it in 2008, but I guess that's not what you wanted to hear.
So basically you want the concept of a pie-chart but as a single bar (known as a linear gauge in 2008)?
I don't think you can. This is about the limit of what you can do
http://msdn.microsoft.com/en-us/library/aa964128%28SQL.90%29.aspx
You could always buy dundas http://www.sql-server-performance.com/articles/reporting/Enhancing_Reporting_Services_with_Dundas_Reporting_Controls_p1.aspx
essentially this what MS have rolled into 2008