Ciao, this is my scenario.
I'm building a Report with SQL Server Reporting Services.
I have two DataSet:
Continent
Countries
And I build a report like that:
+----+-----------+
| ID | Continent |
+----+-----------+
| 01 | Europa |
+----+-----------+
+----+-------------+
| ID | Countries |
+----+-------------+
| 01 | Italia |
+----+-------------+
| 02 | Switzerland |
+----+-------------+
| 03 | Germany |
+----+-------------+
| 04 | Etc. |
+----+-------------+
My report work good for one page. Now I would generate multiple pages like that:
Page 1
+----+-----------+
| ID | Continent |
+----+-----------+
| 01 | Europa |
+----+-----------+
+----+-------------+
| ID | Countries |
+----+-------------+
| 01 | Italia |
+----+-------------+
| 02 | Switzerland |
+----+-------------+
| 03 | Germany |
+----+-------------+
Page 2
+----+-----------+
| ID | Continent |
+----+-----------+
| 01 | America |
+----+-----------+
+----+-------------+
| ID | Countries |
+----+-------------+
| 01 | USA |
+----+-------------+
| 02 | Equador |
+----+-------------+
| 03 | PerĂ¹ |
+----+-------------+
| 04 | Etc. |
+----+-------------+
How can I generate multiple pages like example above?
Thanks
It looks like combining the two datasets into one and then grouping on continent would work. You can then set a page break after each continent to produce the output you're looking for.
In the group properties select the option to break "Between each instance of a group."
Join the datasets together in TSQL
Select ContinentId = c.ContinentId ,
Continent = c.Name,
CountryId = country.CountryId,
CountryName = Country.Name
From Contintent c
Inner Join Country on Country.ContinentId = c.ContinentId
Add a table (or tablix) to your design surface. Assign the above data set to your table.
Right click on the details group, Add Group | Parent Group
Group by ContinentId
Click OK
Now go to group properties (of parent group) and Set the page break
Will produce the following output.
I had the need for a report that was 4 pages long per each row in Dataset (read: 66 rows, 66 4-page reports). No rows needed to be displayed, just lots of textboxes with values all over the place on all 4 pages from the dataset row.
I added a Tablix control, and deleted the header row and all the columns in the details row. Then I added a Rectangle to that row. Then I right clicked on the left side of the Details row and added a Parent Group Row that grouped on my row's unique ID (in this case, Client ID). Then I went into Group Properties and checked Page Breaks "Between Each Instance of a Group". This was thanks to info in #Trubs answer above.
I made the first rectangle the size of a page more or less (10in, .5in margins) and clicked on the left border and picked "Insert Row, Inside Group Below". Boom. That was my next page. However, just touching that row causes a TextBox to pop into and take the row's shape so you can write something. All fine and dandy, but I had a bunch of textboxes I needed to set up. So, very carefully, I made sure the TextBox was highlighted and right clicked > Deleted it. And then very carefully I went over to tool box and added a Rectangle. Set the Rectangle to page size more or less, and added my various textboxes.
I repeated this for 2 more pages. Always double checking by previewing to make sure they printed out 2 sided (which is a printer setting.)
I looked at each Rectangle property that I used to outline each page and the option "Keep contents together on same page if possible" was checked, which is probably why everything didn't go "sprong" and add extra blank pages. Not sure, but I wasn't too precise about any page breaks anywhere else but what I have outlined above.
I hope this helps someone. Sometimes you don't need a detail section with a bunch of rows of data. This was my solution to generate a 4-page report with each row's data all over the 4-pages. The Tablix was bound to the Dataset.
Related
I have a MySQL table that looks like this (attached below).
I want to simultaneously select (in a single SQL Query) multiple columns (id, Last Name, and username) and import into them into different lists of strings the values if they meet a certain condition (in this case, where color="blue".
+----+------------+-----------+----------+----------------+
| id | First Name | Last Name | Username | Favorite Color |
+----+------------+-----------+----------+----------------+
| 1 | John | Smith | jsmith | Blue |
| 2 | Avery | Nelson | aNelson | Red |
| 3 | Jack | Brooklyn | jBrook | Blue |
| 4 | Arnold | Nam | aNam | Blue |
| 5 | Charlie | Smith | cSmith | Orange |
+----+------------+-----------+----------+----------------+
... Continued
I am trying to select all the required data that meet the condition where color=Blue with the MySQL query of SELECT id, Last Name, username FROM `myTable` WHERE color="Blue". Once this data is selected, I want to import each selected column that meets the color requirement into separate lists.
For example, list FirstName should be list of strings "John, Jack, Arnold" (in that order) and Username list should contain "jsmith, jBrook, aNam" etc. In the end, I want to be able to produce three lists that contain these values which meet the Favorite Color condition in the MySQL database of Blue. How can I do this?
I know that I can make three separate reader queries but I want to do them all in one to save time.
You have not posted VB code so I'm not sure how you intend to use the results but you could load the whole table to a Datatable (unless it is really big), then use Dataview.RowFilter to filter your data with different criteria in-memory, without making any further request to the database backend.
You can see an example in VB.net here
Then you could use LINQ for example to generate a list of string from a datatable or view, see here for an example.
This problem would apply equally if we used listboxes, some combination of list and comboboxes, or even another control type for our first control (textbox, checkbox, etc.) upon which our second control (a combbox or listbox) bases its possible values from which a user could choose.
There are two parts to this problem.
Firstly, having the second combobox's possible values (from which a user can select) be based on a value previously chosen through the first combobox.
After that problem is solved there arises a second. That across the multiple records in the displayed datasheet (or continuous form) the second combobox will blank out values that that were excluded by the last choice of the first combobox.
I answer my own question, solving both parts of the problem ...
Edit 01: Added first and second parts of the problem.
Edit 02: Note to Mods. It is not possible for the question to be more focused. It expresses a single focused problem. If anything the question could be changed to be more general, swapping out "combobox" for "control". However that's undesirable as: a combobox is the more common scenario; and the general applicability is explained in the body of the answer..
Edit 03: Note to mods ...
Just to emphasize why the question is as focused as it reasonably ought be. There exists online the nearby less focused problem E.g. at O'Reilly > Limit the Items in One Combo Box Based on the Selected Item in Another.
But that only addresses the case where you have a combo on a main form and subform (a solution that could also apply to two combos on a form in the standard "form view"). Indeed the O'Reilly page warns that in the more focused circumstance "Using related combo boxes in the detail section of a continuous form" that this "can cause problems" with the implication these are unsolvable problem. (This is the same problem if the form is datashet view).
That focused problem, the specific problem my question references, is also raised repeatedly on stack overflow. E.g.
Using cascading combo boxes in a datasheet subform
Change control source only selected combo box in continous form
Dependent Combobox in a Datasheet in Access?
But each of those posts are less ideally formed in manner which mine has sought to overcome. The first and second aren't in the form of a question (and arguably neither is the third even with the presence of a question mark). And all three of these don't capture (in the text of the "question") that the problem applies just as well to a form in datasheet view as with continuous view (they pick out one view over the other). In that way they are wrongly too focused.
In addition each of these posts have chosen answers that wrongly assert there is no solution to this problem, sometimes with vague allusions to workarounds. My answer provides a detailed solution to something this is generally dismissed on stackoverflow as unsolveable.
Overview
Broadly this is achieved by having the second combobox be based on a parameters query that references the first combobox.
But after you've done that the relatively harder part of the problem emerges. Across the multiple records in the displayed datasheet (or continuous form) the second combobox will blank out values that that were excluded by the last choice of the first combobox.
That problem is solved by temporarily altering the Row Source of the second combobox during the Enter event of that combobox to a "selecting relevant" dataset (that limits possible values in the second combobox based on the value selected in the first). Then on the Exit event of the second combobox the RowSource restores a "display relevant" dataset (that doesn't limit possible values in the second combobox based on the value selected in the first).
Details
Our Example
For all objects, tables apart, I'll use Reddick's RVBA Naming Conventions. Specifically from Host Application and Component Extensions Tags > Access Objects. For tables I won't have any "Hungarian" prefix (this is just a personal quirk of mine).
In our example we'll have a frmCashInflow (Form), displayed as a datasheet, that (obviously enough) tracks cash inflow to a business.
Our first combobox will be cboCashInflowCategory.
Our second combobox, which is to restrict its possible values based on the value chosen in the first combobox, will be cboCashInflowSubcategory.
The relevant lookup data is as follows:
CashInflowCategory (Table)
| CashInflowCategoryID | CashInflowCategoryName |
| -------------------- | ----------------------------------------------------- |
| 1 | Sales |
| 2 | Bank Interest Received |
| 3 | Refunds from Suppliers |
| 4 | Property, Plant, and Equipment - Asset Disposal Sales |
| 5 | Intangible Assets - Asset Disposal Sales |
| 6 | ATO Refunds Received |
| 7 | Contributions from Owner |
CashInflowSubCategory (Table)
| CashInflowSubcategoryID | CashInflowSubCategoryName |
| ----------------------- | -------------------------------------- |
| 1 | Retained-copyright-software-copy-sales |
| 2 | Services |
| 3 | Notice of Assessment, Business Portion |
| 4 | Business Activity Statement |
Next we have a table the expresses the subcategories that belong to particular categories. For the sake of a full example we'll allow that some categories don't have any subcategories.
CashInflowCategorySubcategory (Table)
| CashInflowCategorySubcategoryID | CashInflowCategoryID | CashInflowSubcategoryID |
| ------------------------------- | ----------------------------------------------------- | -------------------------------------- |
| 1 | Sales | Retained-copyright-software-copy-sales |
| 2 | Sales | Services |
| 3 | Bank Interest Received | |
| 4 | Refunds from Suppliers | |
| 5 | Property, Plant, and Equipment - Asset Disposal Sales | |
| 6 | Intangible Assets - Asset Disposal Sales | |
| 7 | ATO Refunds Received | Notice of Assessment, Business Portion |
| 8 | ATO Refunds Received | Business Activity Statement |
| 9 | Contributions from Owner | |
Some aspects of this table:
The fields CashInflowCategoryID and CashInflowSubcategoryID actually store numbers. In design view of the table, on the [Lookup] tab a Display Control of "Combo Box" is set, with Row Sources of CashInflowCategory and CashInflowSubCategory respectively. Other values on the [Lookup] tab are set appropriately/as desired. The net effect is that in the table above we see the user friendly ID names (as above) rather than the raw numeric IDs.
Also in table design view we create an Index called idxCashInflowCategorySubcategory comprising the two fields CashInflowCategorySubcategoryID and CashInflowSubcategoryID . For this index "Ignore Nulls" is set to No. Unique is set to "Yes". This index is created (and a single field primary key is added) rather than setting the primary key to comprise both CashInflowCategorySubcategoryID and CashInflowSubcategoryID to allow that some Categories have no Subcategories. This is a common, although not a necessary, requirement - depending on the business rules.
In the relationship diagram referential integrity is set between CashInflow (table) and:
CashInflowCategorySubcategory (table), via both CashInflowCategorySubcategoryID and CashInflowSubcategoryID. That is, rather than
CashInflowCategory (table) and CashInflowSubCategory (table) separately.
This is to enforce that in CashInflow (table) a Subcategory can't be chosen that isn't associated with a Category in the way expressed by CashInflowCategorySubcategory (Table).
In the relationship diagram referential integrity is set between:
CashInflowCategorySubcategory (table) and CashInflowCategory (table); and between
CashInflowCategorySubcategory (table) and CashInflowSubcategory (table)
That is, the CashInflowCategorySubcategory table expresses a many-to-many relationship between CashInflowCategory (table) and CashInflowSubcategory (table).
The Procedure
We have the tables as above. We have frmCashflow bound to CashInflow (table), the table that adds our transactions.
On frmCashflow add cboCashInflowCategory.
Control Source: CashInflowCategoryID
Row Source: CashInflowCategory
Row Source Type: Table/Query
Bound Column: 1
Limit to List: Yes
Column Count: 2
Column Widths: 0cm;1cm [We hide the ID, as this is numeric and not user friendly]
List Width: 11cm [Some generous value to show our user friendly Category name]
Create a parameter query qprmCashInflowSubcategory in the Query By Example (QBE) grid, to produce the SQL as follows.
SELECT CashInflowSubcategory.*
FROM CashInflowSubcategory INNER JOIN CashInflowCategorySubcategory ON CashInflowSubcategory.CashInflowSubcategoryID = CashInflowCategorySubcategory.CashInflowSubcategoryID
WHERE CashInflowCategorySubcategory.CashInflowCategoryID=[Forms]![frmCashbook]![sbctCashInflow].[Form]![cboCashInflowCategory];
Note that the combobox cboCashInflowCategory on the form is referenced. This is what powers our second combobox cboCashInflowSubcategoryto confine it's values to that selected by the first combobox cboCashInflowCategory.
On frmCashflow add cboCashInflowSubcategory
Control Source: CashInflowSubcategoryID
Row Source: qprmCashInflowSubcategory [Temporarily set, to demonstrate a problem]
Row Source Type: Table/Query
Bound Column: 1
Limit to List: Yes [Attempting to set to "No" causes all sorts of strife]
Column Count: 2
Column Widths: 0cm;1cm [We hide the ID, as this is numeric and not user friendly]
List Width: 8cm [Some generous value to show our user friendly Category name]
Add the following to cboCashInflowSubcategory's On Enter event (among several possible events where you might be tempted execute the Requery) .
Private Sub cboCashInflowCategory_AfterUpdate()
Me.cboCashInflowSubcategory.Requery
End Sub
Open frmCashflow (in datasheet or continuous form view), select a "filtering" value from cboCashInflowCategory. Namely "Sales" or "ATO Refunds Received". Move to cboCashInflowSubcategory and observe that the values are successfully filtered. E.g. If in cboCashInflowCategory you selected "ATO Refunds Received" then in cboCashInflowSubcategory the available choices are only "Notice of Assessment, Business Portion" and "Business Activity Statement" (and we can't see "Retained-copyright-software-copy-sales" nor "Services" ).
However, you'll also see a new problem. The only values displayed in cboCashInflowSubcategory, across the whole datasheet, will be confined to the lastly chosen value in cboCashInflowCategory. E.g. You'll get either ...
| Date | Category | Subcategory | Amount (Inc. any GST) |
| :--------- | ----------------------------------------------------- | -------------------------------------- | --------------------- |
| 2020-07-28 | ATO Refunds Received | Notice of Assessment, Business Portion | $70.00 |
| 2020-07-29 | ATO Refunds Received | Business Activity Statement | $2,000.00 |
| 2020-09-19 | Intangible Assets - Asset Disposal Sales | | $500.00 |
| 2021-01-26 | Property, Plant, and Equipment - Asset Disposal Sales | | $100.00 |
| 2021-03-11 | Sales | | $3,000.00 |
| 2021-04-17 | Sales | | $1,000.00 |
.... or, if "Sales" was lastly chosen in cboCashInflowCategory ...
| Date | Category | Subcategory | Amount (Inc. any GST) |
| ---------- | ----------------------------------------------------- | -------------------------------------- | --------------------- |
| 2020-07-28 | ATO Refunds Received | | $70.00 |
| 2020-07-29 | ATO Refunds Received | | $2,000.00 |
| 2020-09-19 | Intangible Assets - Asset Disposal Sales | | $500.00 |
| 2021-01-26 | Property, Plant, and Equipment - Asset Disposal Sales | | $100.00 |
| 2021-03-11 | Sales | Retained-copyright-software-copy-sales | $3,000.00 |
| 2021-04-17 | Sales | Services | $1,000.00 |
... while what we want is to display all Subcategories ...
| Date | Category | Subcategory | Amount (Inc. any GST) |
| ---------- | ----------------------------------------------------- | -------------------------------------- | --------------------- |
| 2020-07-28 | ATO Refunds Received | Notice of Assessment, Business Portion | $70.00 |
| 2020-07-29 | ATO Refunds Received | Business Activity Statement | $2,000.00 |
| 2020-09-19 | Intangible Assets - Asset Disposal Sales | | $500.00 |
| 2021-01-26 | Property, Plant, and Equipment - Asset Disposal Sales | | $100.00 |
| 2021-03-11 | Sales | Retained-copyright-software-copy-sales | $3,000.00 |
| 2021-04-17 | Sales | Services | $1,000.00 |
To give us what we want, to both restrict cboCashInflowSubcategory's possible values based on the value chosen in cboCashInflowCategory but also display all chosen cboCashInflowSubcategory values as above, we do the following ...
Undo the previous step. That is delete the cboCashInflowSubcategory's On Enter code and event.
Set cboCashInflowSubcategory's Row Source to CashInflowSubcategory (table). This will be our "display relevant" dataset.
Temporarily set cboCashInflowSubcategory's Row Source to a "selection relevant" dataset, then restore the "display relevant" dataset. Add the following event code (verifying this is hooked up correctly in the comboboxes' property sheet)
Private Sub cboCashInflowSubcategory_Enter()
' Temporarily set a "selection relevant" dataset
Me.cboCashInflowSubcategory.RowSource = "qprmCashInflowSubcategory"
Me.cboCashInflowSubcategory.Requery
Me.cboCashInflowSubcategory.Dropdown ' Optional
End Sub
Private Sub cboCashInflowSubcategory_Exit(Cancel As Integer)
' Restore the "display relevant" relevant dataset
Me.cboCashInflowSubcategory.RowSource = "CashInflowSubcategory"
Me.cboCashInflowSubcategory.Requery
End Sub
Everything should now work seamlessly in the UI as desired.
Edit: Added 'Unique is set to "Yes".' for idxCashInflowCategorySubcategory
I'm working with SharePoint Lists, I have 2 Lists for this issue i.e. Movies & Theatres. Only one list is used tough, because Theatres reference a movie.
(I know this is weird but I'm not actually working with movies and theatres, it's just using an analogy so anyone could understand the problem so let's assume each Theatre only plays a single movie :-P )
So from the Theatres list I create a dataset with following fields: Linked_Movie (Title), Country, Theatre_Number.
I want to create a report that shows a tablix that lists all Movie-titles with all the countries it's shown in and a count of the theatres that are playing that movie. So the tablix should look like example below:
MovieTitle | Country | # of theatres
| |
Movie 1 | Country A | 5
| Country B | 10
SubTotal | 2 | 15
| |
Movie 2 | Country C | 15
SubTotal | 1 | 15
| |
Total | 3 | 30
I have already created a tablix which groups on Linked_Movie first and Country second. Then in the details-section I just count the theatres that play that certain movie in that specific country. To achieve this I created a second dataset with the exact same data so I could use LookUpSet.Length. But even though my calculations are correct the tablix still generates a row for each individual theatre. So my tablix actually looks like example below:
MovieTitle | Country | # of theatres
| |
Movie 1 | Country A | 5
| | 5
| | 5
| | 5
| | 5
.... | ... | ...
So if anyone knows how I would be able to achieve a tablix like the first example that would be greatly appreciated.
If anything is still unclear please don't hesitate to ask.
Kind regards
Gravinco
I was able to solve it by adding a calculated field to the dataset named MovieCountry.
After this I put the expression below as the condition for 'Row visibility' and the visiblity of the '=(Details)' properties:
=iif(Fields!MovieCountry.Value = Previous(Fields!MovieCountry.Value), True, False)
This way I only get a single row for each movie and country combination.
Any questions are always welcome!
I have a listbox that displays the result of a query. However how the database has been designed all the information is in rows as there is a magnitude of possible controls to one product.
I.e
Productname | Control 1 | Control 2 | Control 3 | Control 4 | Control 5 ........ | Control 14
Product 1 | 010101010 | 101010101 | ..........
I would like the List box to show the column heads on the left rather than the top, or the combo box to List the part no's.
Is this a property issue or is it done through VBA?
So, for a combobox on one of my projects' main screens, I utilize a table as a Row Source. (Technically it's a query I suppose but it's only 2 fields from a table)
I have a table that looks like this:
+--------------+----------------+
| QuickEntryID | QuickEntryName |
+-------------------------------+
| 1 | Add Part |
| 2 | Add Control |
| 3 | Add Product |
+--------------+----------------+
(All of this can be done behind the scenes by making a few selections in the wizard.)
I use a SELECT statement to populate the combobox from this table. When right clicking on a combobox, in the Data tab, there is Row Source, this is where I put my query.
SELECT [QuickEntryLaunchTbl].[QuickEntryID], [QuickEntryLaunchTbl].[QuickEntryName]
FROM QuickEntryLaunchTbl
ORDER BY [QuickEntryName];
I format the column widths, under the Format tab: 0";1" (Or when you create the combobox, one of the steps is a checkbox to "Hide ID Field (recommended)" and I select that.
You should never have to try and arrange the Column name as the row source for a combobox, because that's not actual data. Now, if there was a table like this:
+--------------+----------------+
| PartID | PartNumber |
+-------------------------------+
| 1 | 010101010 |
| 2 | 110101010 |
| 3 | 210101010 |
+--------------+----------------+
Then your combobox would show the PartNumber in the drop down list, and it would actually be usable data.
I guess you could always create another table with column names as rows, but I'm not sure what use that would be.
I have a matrix report in SSRS 2008 displaying information about a Company and the total points earned by each company for a selected Quarter.
Example
Company | Current | Previous | Diff |
--------------------------------------
| Q3 2008 | Q2 2008 | |
--------------------------------------
Comp 1 | 2000 | 1500 | 500 |
--------------------------------------
Comp 2 | 1200 | 1400 | -200 |
--------------------------------------
In my SSRS report I have a RowGroup based on my Company field from the data set ([Company]).
And I have a ColumnGroup based on my Quarter field from the data set. Sorting in the group is reversed because I want to start with the latest quarter.
I have parameter for selecting companies and 2 parameters for selecting quarters (QuarterCurrent and QuarterPrevious).
As a side effect if I select 2 quarters that are not consequent I get more than 2 columns which is something that I do not like.
But then I thought that if I could hide the columns in the middle and display on the First (QuarterPrevious) and the Last (QuarterCurrent) I will be able to compare any quarter to any other quarter.
My question is about hiding the columns in the "middle" of the matrix. I am trying to
achieve something like this:
Company | Current | *(HIDDEN)* | Previous | Diff |
----------------------------------------------------
| Q3 2008 | *Q2 2008* | Q1 2008 | |
----------------------------------------------------
Comp 1 | 2000 | *1500* | 1300 | 700 |
----------------------------------------------------
Comp 2 | 1200 | *1400* | 1250 | -50 |
----------------------------------------------------
So in the end I will have only the Current and the Previous columns visible.
I tried the following approaches:
Setting the Column Visibility property to:
=IIF(StrComp(Fields!Quarter.Value,First(Fields!Quarter.Value))=0 OR StrComp(Fields!Quarter.Value,Last(Fields!Quarter.Value))=0,False,True)
In my understanding this should set the property Hide to False to each column that is equal to the First and the Last values in the sequence, and to True to all the others. However it does not happen like this, but all columns were hidden.
I tried setting the same expression to the Visibility property in Group Properties. Still has the same effect - all columns were hiding.
Edit : format code
Instead of two parameters for your quarter selection, have you tried a multi-select dropdown parameter ?
I solved the issue in the following way:
Instead of using parameter with range (From and To) I used a parameter with two values and my queries is not BETWEEN From and To, but rather IN [From, To]. The values of From and To can be any 2 quarters (they can even be switched - From does not have to be before To).