I've got an Access 2007 database where I created a report showing projects (using tblProjects). I then created a sub-report showing project history (using tblProjectHistory). The sub-report is linked to the parent report by fldProjectID (tblProjectHistory) and projectID (tblProject).
The layout is such.
::Project information
--> project history information
++++++++
::Project information
--> project history information
(repeat)
The projects list out correctly, and any project history is also appropriately underneath the respective project. No overlap at all.
I'm wanting to limit the number of project history records in the sub-report to no more than 5 for each project. I've tried modifying the sub-report record source to have "TOP 5" in it. but then it ends up limiting the overall number of sub-report records - no matter if they are under one project or not.
Any idea how I could accomplish that mission? Thank you in advance for your time.
You were on the right track with TOP 5 but I can't think of a way you can do this using the tables themselves as a datasource for the subreport.
I would recommend using a query as the data source for the subreport based on the project ID in the report WHERE projectID = [reports]![reportname]![report project ID field]. You will then be able to group relevant records together by project and select the TOP 5 records for the subreport.
Related
So I have the below case in crystal reports
Main Report which has a query that shows the batch details of an invoice
Sub-report which shows the details of the batches included in the main report but are not included in that document. So for example
Invoice A has 10 items all with the same batch (this will show in the main report)
Invoice B, C, an D has 3 more items in the same batch (so total 13 items for that batch in 4 different documents) and the 3 items that are not in document A is what appears in the sub-report.
Now it's easy to achieve that in Crystal Reports because you can link sub-reports with fields to filter directly without linking the queries, however since CR is not a database engine the filtration is super slow and to solve that I need a solution in an SQL query:
I tried converting it to UNION ALL so it's
Main Report
Union ALL
Sub Report
The problem is I am unable to replicate the sub-report case since the grouping needs to be by Document then Batch and the 3 items from the sub-report are not on the same document so they are not grouped by the same dimension now and that ruins the report.
I know it's not logical but after trying all the solutions that came to my mind I thought maybe someone more experienced would have a different opinion, basically for every invoice in the main report I need to show all items that are not in that specific invoice so right now I have no links because the Item is not the same, the document is not the same, and only the batch is the same but that's a many to many link.
EDIT: For simplicity let's say this is the main query
SELECT
T0.DocumentNumber,
T2.ItemCode,
T2.ItemName,
T3.BatchNumber,
T3.Quantity
FROM DocHeader T0
JOIN DocRows T1 ON T0.DocumentEntry = T1.DocumentEntry
JOIN ItemMaster T2 ON T1.ItemCode = T2.ItemCode
JOIN BatchTransaction T3 ON T1.Document Entry = T3.DocumentEntry and
T3.DocumentType = T1.DocumentType and T3.DocumentLine = T1.DocumentLine
The report is grouped by Document Number, so what i need is the same query but for every other document number that is not in the main query joined on the main query. The 2 problems are 1. They can leave the document number parameter blank and select all the documents in the table so this process needs to happen for each document seperately. 2. the document number in the sub query will never be the same so the grouping is an issue because the report needs to be grouped on the main query document number.
It would help if you wrote out your main query and some of the secondary queries you've tried, but assuming I understand your issue correctly, you should be able to just create an additional JOIN on the Batches table. This will have your SQL query list off ALL the Item rows for the Batch, then you can try to use conditional formatting and/or grouping in Crystal to to show/hide the rows as needed.
Alternatively, using the query described above, you may be able to use the linked Invoice Numbers you're now getting from your main report query to drive your Sub-Report, as opposed to going by the Batch # -- this may result in better performance.
EDIT: Based on your comment and update, I think the right approach here is to create a Stored Procedure. Doing a single query is probably not going to work, I took a crack at it and it's not worth the hassle.
Using a Stored Procedure you can create a table variable in memory, add the main invoice records to the table, then add the records for the secondary Invoices linked by the Batch number. Use some kind of column/flag in your table that indicates whether it's a 'Main Invoice' record or not, and use this flag to drive the Crystal display logic for how you want to show the main vs secondary/linked invoices.
It's doable!
So my problem here is that I have a Part number which lives in two warehouses hence it has two bin locations. If I just use =Fields!PrimBin.Value it only ever returns the first location. I need to display the PrimBin if the location is from a specific warehouse. To get the warehouse I use =Fields!WarehouseCode.value
What I need to do is only show the PrimBin.Value of MAINWHSE and not CELLWHSE
Thanks in advance.
Ok so the database it quite vast. However, for the information required I am using two tables. Part and PimWhse.
Part shares the Product ID to PrimWhse. In PrimWhse each partID has two locations "MAINWHSE", "CELLWHSE "and 1 bin to pick in each warehouse giving to possible locations.
So WarehouseCode.Value will have the information for which warehouse the part is located. and PrimBin.Value will have the warehouse position ID stored in it.
This is all setup via report style within the Epicor system. When I create a query in business activity to look in MAINWHSE it shows the correct information.
However, in the report data builder I'm not able to set this query so I assume SSRS will be able to see of both theses possible values for PrimBin.Value!? If not I guess I need to work out how to add a query to report data builder, which at the moment does no seem possible?
Thanks again.
Basically, say I have a report A and I want to add a link column to it, and I set its target to a page in the application...the page its referring to has another report (lets call it B)
Is it possible for me to somehow make it so that table A's link column opens the page with Report B with rows that have the same column value for one of their columns?
Example here:
A
Name Num1 Num2
--------------
A 5 3
B 3 3
C 4 2
B
Name Quantity Serial
--------------------
D 2 3
E 1 8
F 4 6
So if I click the link column for row A, I want it to open report B and only shows rows where its Num2 = Serial, so only row D would show since it is the only one that equals 3
Using Report Linking to Filter Other APEX Report Outputs
I had some fun with this one although. The "A" and "B" stuff was pretty dry, so I decided to create a data set that was more engaging, and perhaps clearer to understand for the rest of us... :) This is how the data-ecosystem was broken down, and the way I fulfilled the OP requirements.
The Test Schema:
Welcome to the manufacturing facilities of the "Recipe Stack" Food Works. The schema design and ERD (Entity Relation Diagram) is below, with the sample data used for this demonstration:
The data relations are as follows:
The staff at the Stack Food-Works keeps an inventory of all ingredients for the types of meals and prepared foods they manufacture. Each ingredient has a unique ID (INGREDIENT_ID) and the staff tracks the amounts of each item in their pantry.
Each ingredient can be used in multiple recipes, but they will be used exactly once for a given recipe.
The ENTREE_RECIPE table has a COMPOSITE KEY which means it is the combination of the two pieces of this composite key (ENTREE_NAME and INGREDIENT_SEQ) that should be unique.
There is a FOREIGN KEY relation between the INGREDIENT_ID values of both tables.
Report Display Requirements (APEX and SQL Design Elements)
Selecting an item from the FIRST report is used as the input and the restriction/filter criteria of the second report.
User Case #1:
User Selects a Ingredient ID from the list of available ingredients in the pantry.
Input from (1) filters output of the RECIPE REPORT. This is a list of all the recipes that have the chosen ingredient in their formula.
User Case #2:
User Selects an ENTREE_NAME from the RECIPE REPORT. The ENTREE_NAME is used to deliver a third report: the RECIPE FORMULA which is the full recipe for the entree item that was selected from the previous report.
Testing Tools
(You usually need these these for the more complex pages, so it's a good start to use or develop them for the easier ones...)
I made my own, but you can also invoke the SESSION link on the developer's tool bar at the bottom of the APEX page on your running application (when it is displayed).
Here's my idea; it's a header region that also has a button to RESET input values so that I can clear the cache and retest or try other examples. I'll show later how you can use this link to see what is going on. You can see it in the discussion of testing at the bottom of this guide.
APEX Report/Page Design and SQL Parametrization
My columnn linking scheme looks similar to the previous post such as the one from FTaveras. This is how my linking works. What's different is that I do not go to another page, I simply go BACK to the same page I came from. Redirects and Branches apparently don't care if they are simply returning to the same location.
What is different on the return trip is that page parameters that were originally null or unpopulated NOW have a value. That value now brings life to the reports on the page that were empty.
Step 1: The PANTRY REPORT
Output: Query all items from the FOOD_SUPPLIES table.
Inputs: Supply links by INGREDIENT_ID to filter the RECIPE_REPORT output.
How to do it: (hint) To accomplish this, define the report column/field value in your report layout design page as a "linked" column and assign its value as a page item. The page item will be referenced in the SQL query of the next report...
Step 2: The RECIPE REPORT
Output: Query all records from the ENTREE_RECIPE table which have the INGREDIENT_ID from Step 1 within their formula.
Input: Supply links by ENTREE_NAME to filter the RECIPE_FORMULA output.
How to do it: (hint) Include the page item defined from Step 1 within the SQL query of this report:
SELECT * FROM entree_recipe
WHERE ingredient_id = :P3_INGREDIENT_ID
Step 3: The FORMULA REPORT
Output: Query all records from the ENTREE_RECIPE table which have the ENTREE_NAME selected from Step 2.
Debug and Test Run
Most will be able to get this far without any problems. If not, here are a couple of examples of how you can debug and test your work. There may be some built-in tools and packages that already exist within Apex, so any suggestions on alternate approaches are welcome in the comments...!
Using the APEX Developer SESSION Output
After selecting the inputs for the trial run, click on the SESSION link on the developer toolbar at the bottom of the page. This is an example output:
Note that the page items that were set for that session are displayed. The inputs I used for this test were:
INGREDIENT_ID: 6432
ENTREE_NAME: peach cobbler (fresh)
Extra Credit: This one is an alternate approach. It may be useful to design something like this as an add-on to any app you design. You do not need to remove it from your app when you push it to production because there is a "conditional display/suppress" feature for page regions. (check it out)
Simply set a global parameter as a "mode" on your Apex app. Set the value to "DEBUG" or "TEST" or whatever and key all your instances of this page region to display only when the global parameter is set to it.
Wrap Up and Discussion
Hopefully, you've enjoyed your visit to the "Stack Food Works" (no tasting or sampling from the line, please).
This has been more of a holistic approach to Apex app design. It helps to have a methodology to map out each step, and a way to check your work at both the beginning and the end of your development process. Using smaller examples like this demo to apply these methods provides a chance to understand Apex development as a Software Creation PROCESS.
Yes it's possible.
On page B, add and hidden Item name for example P(#)_SERIAL where (#) is your current page number.
Modify your query and add one line like AND SERIAL=:P(#)_SERIAL.
On Page A go to "Report Attributes" tab on the report region, click edit.
On the column link section configure your link to page B and set the hidden item on page B to the value on report column of page A.
Name: Item 1 [P(#)_SERIAL] Value: #Num2#
Demo
So to summarise the problem, I have a report which has two datasources - and is really two reports stuck to each other. I want the second part of the report to display data based on what the first part of the report is showing.
To go into more detail, the situation is as follows. I have two database tables - lets call one Customers, and the other Orders.
Customers contains data about the customers.
Orders contains a link to customers and contains the person's orders.
The report itself is supposed to display some sort of letter in part 1:
"Hello [CustomerName], you have an ongoing balance of [TotalBalance] bla bla bla..."
and a list of all the orders he has made in part 2
"Order 1: Item 1: 1 euro
Order 2: Item 2: 2 euro ..."
Originally these were two separate reports which we were generating one record at a time, outputting as pdf files and merging them using third party software such that the letter and the list of orders were next to each other. The problem is that this system will need to generate hundreds of them at a time, and it was taking ages. So now I want to pass a pair of large data sources and generate them in batches (call them 600 at a time) - which works faster.
So how can I force the second tablix which uses a different datasource, to filter based on what is in the first tablix with its own datasource?
I've looked at subreports, but they only work using reporting server and these are local reports.
Anything I can do ? I'm worried that its not possible.
There's no reason subreports won't work with local reports.
I recommend you download the samples from this site ReportViewer Samples. The project named "SupplyingData" shows how to load data into a subreport.
I have a spreadsheet in excel with three headers:
Project Name
The name of a project i'm working on.
Requested Role
The job title/profession of the project employee. (example: mechanic, manager, engineer)
Name
The name of the employee.
When i click on the Person's name i want another page or tab (specific to this person) to appear showing details about them such as their name, job title, how long they worked, what project they are doing... etc. (similar to a Facebook profile)
When i click on the project name i want another page or tab (specific to this project) to appear showing details about it such as the requirements, the deadline, who is currently working on it... etc.
Furthermore, i would like to set up two levels of access:
Managers:
People who can add new information but not change or delete existing information
(write-only permissions)
Administrators:
People who can have full access to all information.
All highest level of access.
I don't know how i would go about displaying and/or organizing so much information in a vb.net application. if anyone could provide some suggestions as to some possible layouts of the GUI it would be greatly appreciated!
Additional Details:
For the specific pages i was thinking of using the tab control but i want it so that i can search through the list of projects or names, select one, and then it brings up the page about it.
The levels of access is the least of my worries... although it is still a worry.
You don't want to store that information in an excel spreadsheet, a database is much, much better. For what you've described here I'm going to assume that you have Projects and Employees, and that multiple Employees can work on a project. You'll need a few tables then:
Project
ProjectSeq 'Int - unique sequence for this project record
Name 'String - name of project
Descr 'String - description of project
... 'Various - other fields as needed
Employee
EmployeeSeq 'Int - unique sequence for this employee record
Name 'String - Name of employee
Title 'String - Job title of this employee
IsManager 'Boolean - Is this employee a manager?
IsAdmin 'Boolean - Is this employee an administrator?
... 'Various - other fields as needed
ProjEmpl
ProjEmplSeq 'Int - unique sequence for this project-employee record
ProjSeq 'Int - link to project record
EmployeeSeq 'Int - link to employee record
... 'Various - other fields that apply to this project-employee combination
Once you have your tables all set up and populated with data, you'll want to read the data and transfer it to your .NET application. There are a few ways of doing this, you'll have to decide which works best for your needs. I'm a big fan of DataSets, they always work nicely.
To fill the grid, you'll need to use a sql statement that fills a datatable from the three tables (I'm using notepad as my IDE, so this may not be exact):
SELECT pe.*, p.Name as ProjName, e.Name as EmplName, e.Title
FROM ProjEmpl pe, Project p, Employee e
WHERE p.ProjectSeq = pe.ProjectSeq AND
e.EmployeeSeq = pe.EmployeeSeq
To display the data to the end user, you would use a DataGridView control. Set the datagrid.DataSource to use the datatable you just populated and the data should show up.
To display the related Employee & Project information, I'd use a tab control underneath the datagrid. One tab for Project, and one tab for Employee. Use individual controls for each field in the table. When the user changes rows in the datagrid, load the related Project and Employee information for that row into two datatables and populate the controls from that.
Lastly, to set permissions on the program you'll need to have the employee log onto the application. Once they've logged on you can look them up in the Employee table, find out if they are a manager or an administrator, and set the permissions accordingly.