I am working on a report in Access 2013 I need to seperate the first 20 records in a column that contain a value and assign a name to them. Such as at 1-20 I need it to insert Lot 1 at 21-40 need to assign Lot 2 etc... The report needs to be separated by lots of 20. I can also just insert a line when it reaches sets of 20 without a name if that makes it easier. Just need something to show a break at sets of 20.
Example: As you can see the report is separated by welder stencil. When the count in the VT column reaches 20 I need to enter a line or some type of divider to separate data. What our client is asking for is we separate the VT in sets of 20. I don't know whats the easiest way to accomplish this. I have researched it but haven't found anything.
Example Report with Divisions
Update the report's RecordSource query by adding "Lot" values for each row. There are multiple ways of doing this, but the easiest will be if your records already have a sequential, continuous numerical key. If they do not have such a key, you can research generating such sequential numbers for your query, but it is beyond the scope of this question and no details about the actual data schema were supplied in the question.
Let's imagine that you have such a key column [Seq]. You use the modulo (mod) and/or integer division operators (\ - backslash) to determine values that are exactly divisible by 20, e.g. ([Seq] - 1) mod 20 == 0.
Generate a lot value for each row. An example SQL snippet: SELECT ("Lot " & (([Seq] - 1) \ 20)) As LotNumber ...
Utilize Access report sorting and grouping features --grouping on the new Lot field-- to print a line and/or label at the start of each group. You can also have the report start a new page at the beginning or end of such a group.
The details about grouping can be found elsewhere in tutorials and Access documentation and are beyond the scope of this question.
Related
I'll do my best to describe my problem. I'm modifying a report in Access 2010. I have a text box in my detail section that displays the weight of a pallet with boxes on it.
=[PalletWeight].
The PalletWeight field is generated from a SQL query that grabs this information from our database. As it so happens in the database that field appears like so:
100.000000000. I don't know the data type for that field in the database because looking isn't as simple as opening SQL Server, but =CDbl([PalletWeight]) does work so unless someone tells me they need to know I didn't obtain that information for this question.
The pallets are grouped by item. So item 1 might need to be carried on 3 pallets, item 2 might need 4, etc...
As mentioned earlier, I used CDbl on the textbox to convert the value to appear as 100.00 on the actual report.
I need to add a text box that calculates percentage. For each item, the total weight of the pallets needed per item is a certain percentage of the grand total weight of all pallets produced.
When I attempted do something like the following I get the #Type! error.
=Format([PalletWeight / Sum(PalletWeight) * 100, "Percentage")
I've also tried to refer to the text box by name (name reference) to perform operations on its value instead of the value contained in the text box.
=Format([TextBox1] / [Textbox2] * 100), "Percentage").
This report has various grouping sections. I've tried using hidden text boxes to hold the values I want to manipulate and referencing those but it seems as soon as I use arithmetic I get the #type!.
I'm using the expression builder in the properties Control Source section. Any help would be greatly appreciated.
You either need to modify your query to add another calculated field
say dblPalletWeight =CDbl([PalletWeight])
and then use that in your formula
=Format(dblPalletWeight / Sum(dblPalletWeight) * 100, "Percentage")
Or modify your formula to do the conversion on the fly
=Format(CDbl([PalletWeight]) / Sum(CDbl([PalletWeight])) * 100, "Percentage")
So, I have a problem in Report Builder that is just driving me absolutely crazy.
I have two dataset; one called DS_Grades and the other DS_Pupils. I want to do a simple LookUp based on PupilID, a field that is in both datasets, and return a grade from DS_Grades into a Matrix based on DS_Pupils.
The formula I am using is:
=LookUp(Fields!PupilID.Value, Fields!PupilID.Value, Fields!Grade.Value, "DS_Grades")
I have confirmed that:
1) DS_Grades has the right PupilIds
2) There are actually values in the Grades field
3) Both PupilID fields (I.E. in both datasets) are definitely Integers and not text.
Moreover, if I add a calculated field to DS_Grades called "test" and populated with the value 208301, which is a valid PupilID, then I can enter the below formula and it works fine:
=LookUp(208301, Fields!test.Value, Fields!Grade.Value, "DS_Grades")
So, the LookUp itself must be matching properly, which means that the PupilID fields must be causing the problem, but I have quintuple freaking checked them and they definitely have the right values, in the right format. I am at a total loss as to why SSRS thinks that they don't match.
Help please!
Got it! Some filtering was at Dataset Level (instead of query where I normally do it) that was throwing the whole thing out of joint. Removed that, and it's fine.
I have a report where users can select items from various location. And I have 3 datasets performing calculations where the third dataset takes the sum where item number is 4942200 and then calculates the values (as shown below):
=SUM(IIf(Fields!masterno.Value= "4942200",Fields!Owned.Value,0))+SUM(IIf(Fields!masterno.Value= "4942200",Fields!Subbed.Value,0))
This is returning error for some reason. The subbed column is toggled based on parameter (visibility). But before I add the toggle functionality, I want to make sure this is working. Can anyone help. I have also tried:
=SUM(IIf(Fields!masterno.Value= "4942200",Fields!Owned.Value+Fields!Subbed.Value,0))
This seems to fail as well. Help would be greatly appreciated.
I would wrap a CDec around Owned, 0 and Subbed, e.g.
=SUM(IIf(Fields!masterno.Value= "4942200",CDec ( Fields!Owned.Value) ,CDec (0 ) ))+SUM(IIf(Fields!masterno.Value= "4942200",CDec (Fields!Subbed.Value ) ,CDec ( 0 )))
If Owned and Subbed are already Decimals, those CDec's may be redundant. On the other hand SSRS doesnt expose this info and they can change at the whim of the data source.
So, I have this Report:
And this Query:
The report pulls all of it's data from the query. The fields STA1, STA2, STA3, and STA4 are from the Job Order table in which each job has an order set based on Work Stations (Named CU01, CU02, BR01...).
I have attempted to make macros that essentially say
If Reports![Production Router LBPW]![Work Station 1]="CU01" Then Reports![Production Router LBPW]![Run Time 1]=Query![Query Laser Hours by P/N]![Total Laser Hours]
If I understand properly, a series of statements like that could essentially associate each work station with a specific type of time data (Cutting, Bending, Inserting, and Welding), effectively rearranging my fields to automatically display the time data I want in the places I want them. Alas, I don't know enough about macros to make that work and I know even less about VBA. If I can be filled in on a couple lines of code, or something, that would allow me to accomplish this, I'm sure I may be able to figure it out from there.
One approach would be to create various queries, for example:
QueryCU01
SELECT [Cuttime] As Pos1, [Weldtime] As Pos2, [Rivettime] As Pos3, Bend As Pos4
FROM JobOrder
You report would then refer to Pos1, not CutTime. The labels could also be textboxes, so they update automatically as well, for example:
SELECT [Cuttime] As Pos1, "Cut" As lbl1, [Weldtime] As Pos2, "Weld" As lbl2
[Rivettime] As Pos3, "Rivet" As lbl3, Bend As Pos4 "Bend" As lbl4
FROM JobOrder
It is possible that you could simplify further by normalizing your tables.
Tasks table
Job Action Time Machine SortOrder
1 Cut 10 AB 3
1 Bend 4 CD 1
1 Rivet 30 EF 6
So, what I've done is use a series of Switch functions in my query so that the data that is pulled into each query is inserted into each field by a logical statement. For operation name, the logic is as follows:
OP2: Switch([ST2]="PE01","Insert",[ST2]="PE02","Insert",[ST2]="BR01","Bend",[ST2]="BR02","Bend",[ST2]="WE01","Auto Weld",[ST2]="WE02","MIG Weld",[ST2]="WE03","TIG Weld",True,"N/A")
Which essentially means, If ST2=PE01, Then OP2=Insert, elseif ST2=BR01, then OP2=Bend...
Then I set up another swith that says If OP2=Bend, Time2=BendTime... So on and so forth. This way each field contains a value that is entered based on the logical statements and the order of the jobs is determined by the order that I've set when I enterred the station names in the Job Order Table.
I'm working on a rather complex report in Sql Server Reporting Services. My SP returns a dynamic number of columns each of which are dynamically named.
Basically think of a time keeping application. Each column that is dynamic represents a time bucket that time was charged to for that team. If no time was charged to that bucket for the period of time the report covers it doesn't show. Each bucket has its own identifier which i need to be the column headers.
I have an SP that returns this all. It does it by doing a bit of dynamic SQL with an exec statement (ugly i know but I'm on SQL 2000 so a PIVOT option wouldn't work)
I can have an indefinite number of buckets and any or all might show.
I found this - http://www.codeproject.com/KB/reporting-services/DynamicReport.aspx - which is helpful but in the example he has a finite number of columns and he just hides or shows them according to which ones have values. In my case i have a variable number of columns so somehow i need the report to add columns.
Any thoughts?
As long as you know a maximum number of columns, it's possible to do this after a fashion.
First, name the columns with a result from your query, so you can either pass it in to the query or derive it there. Second, just build out the report as if it had the maximum number of columns, and hide them if they are empty.
For example, I had to build a report that would report monthly sales numbers for up to a year, but the months weren't necessarily starting in January. I passed back the month name in one column, followed by the numbers for my report. On the .rdl, I built out 12 sets of columns, one for each possible month, and just used an expression to hide the column if it were empty. The result is the report appears to expand out to the number of columns needed.
Of course, it's not really dynamic in the sense that it can expand out as far as you need without knowing the upper bound.
This can be done. I did this and it works fine.
You don't have to know the maximum number of columns or show and hide columns in my approach. Use a matrix and modify your sp to return dynamic data to the structure mentioned in this blog post http://sonalimendis.blogspot.com/2011/07/dynamic-column-rdls.html
Build 2 related Datasets, first one for the report content, and the second one for the list of its column labels.
The Dataset of the report content must have a fixed number of columns and name. You can allocate some maximum number of columns.
In this example I have the first 2 columns as fixed, or always visible, and a maximum of 4 columns to be displayed by choice through a multivalued parameter, or depends on the query conditions. And as usual, we may have a total as well. So, it may look like this:
Fixed01, Fixed02, Dyna01, Dyna02, Dyna03, Dyna04, Total
The second Dataset with its values will look like this:
Name Label
---- -----
Dyna01 Label01
Dyna02 Label02
Dyna03 Label03
I have omitted the 4th Label to demonstrate that not all columns are being used by a certain query condition. Remember that both Datasets are meant to be related to the same query.
Now create a parameter named, say, #columns; populate its Available Values and Default Values with the second Dataset.
For each of those 4 dynamic columns, set the column visibility with the following expression:
=IIf(InStr(join(Parameters!columns.Value,","),"Dyna01"),false,true)
And for each of their column header Text Boxes, use the following expression:
=Lookup("Dyna01", Fields!Name.Value, Fields!Label.Value, "dsColumns")
As for the Total, here is the expression for its visibility:
= IIf(InStr(join(Parameters!columns.Value, ","), "Dyna01"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna02"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna03"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna04"), false, true)
And here is for its values:
= IIf(InStr(join(Parameters!columns.Value, ","), "Dyna01"), Fields!C01.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna02"), Fields!C02.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna03"), Fields!C03.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna04"), Fields!C04.Value, 0)
That's all, hope it helps.
Bonus, that second Dataset, dsColumns, can also hold other column attributes, such as: color, width, fonts, etc.
I think the best way to do it is add all the columns in your table and edit the visibility property of it with the help of arguments that you get from your SP..this will solve the purpose of dynamic column but when viewing the report you will get a lot of white-space which you can solve with SSRS - Keep a table the same width when hiding columns dynamically? and your report will be ready
I've had the need to do this in the past and the conclusion I came to is "you can't", however I'm not positive about that. If you find a solution, I'd love to hear about it.
An issue that comes to mind is that you need to define the report using the names of the columns that you're going to get back from the stored proc, and if you don't know those names or how many there are, how can you define the report?
The only idea I had on how to do this is to dynamically create the report definition (.rdl file) via C#, but at the time, I wasn't able to find an MS API for doing so, and I doubt one exists now. I found an open source one, but I didn't pursue that route.