I have a set of SQL queries built for SSRS. I am building
reports for multiple customers and my queries apply to all of them
- except I have to replace the company name in the WHERE clause.
Can SSRS create a "template" SQL query and automatically replace
the company name and apply according to the appropriate company
name?
A good way to achieve this is with an SSRS parameter. If you right click the parameters and add one I call mine "client" but you can use company name etc if you prefer.
If you only have a few options for companies you can add them in manually as "available values" but a good option if you have lots of posilbilities is to create a dataset (paramset) from new query that is simply
SELECT
distinct
[Company Name]
From {your table}
Then you can use the "get values from a query" option to automatically fill the parameter drop down box with all the potential options.
After that all you need to do is add
Where [Company Name] = (#Client) or #{whatever your parameter is called}
to your query. When you run the report you should get a dropdown box with all the company names in it and from there you can pick one and it should apply the filter to your data automatically. That way you can build one report and run it for as many companies as you like.
Related
I have a report that uses a client list as a limiting parameter.
where [account no] = #Client
However I really want it to run once each month for every client on the list. The only way I know of doing this is to set up a different subscription for each client but the list is very long and I'm looking for a quick cheat to prevent me having to set up a few hundred subscriptions.
Is there a way to tell SSRS to run the report once for each client in the parameter list and send the results to an email?
This will create a single report that contains every client, not sure if this will be suitable but here goes anyway...
Create a new report.
Add a dataset that contains a distinct list of client account
numbers.
Add a table with a single column and single row
Make the table the width of your report (minus margins)
Set the table's dataset to be the dataset you just created.
In the table cell, insert a subreport
Set the subreport to be your original report
Set the subreport parameter to be the account number from your dataset (from step 2)
You probably want to add pagebreaks on the detail row group etc but this should get you going.
I need to know if there is a way for us to display a single parameter report by pulling the same parameter from multiple drop down controls.
Does SSRS allow us to have multiple controls(drop down ) to pull the same parameter from different set of data.
If you have a server that can access the locations of the first two sets of data, then the easiest way to be for those would be to combine them into one with a UNION and use a single parameter for them.
I'm guessing that may not be possible so you can create a separate dataset and parameter for it.
Then create another parameter for your entered value. Allow these parameters to have a NULL value so that they do not have to be selected.
Create WHERE clause logic in your SQL to deal with the parameters for the LOT_NUMBER:
WHERE LOT_NUMBER IN (#INCOMPLETE)
OR LOT_NUMBER IN (#COMPLETE)
OR LOT_NUMBER IN (#ENTERED)
This will allow uses to choose from the first or second drop downs or enter a third value. The downside is that the user can potentially use all three at the same time.
I'm trying to find a way to pass a parameter from a report to a subreport without resorting to any SQL code or macros (my officemates are non-technical, but still have to use the Access database to run reports, occasionally making tweaks to them.)
I'm working in Microsoft Access 2013. I have a table that contains a list of investments as well as which state those investments are based in. I have a query that pulls data on Investments based on a user-entered State parameter. I then run two reports: one that simply lists the investments grouped on different categories, then a second report that summarizes the investment categories into a table. I've put the summary report at the top of the detailed report as a subreport, but I want to pass the State parameter through from the main report to the subreport so the user doesn't have to enter it twice. Is that possible without resorting to writing any SQL code or macros?
Thanks!
I think I understand what you're trying to do, but please add details if my answer doesn't make sense.
You can pass user entered information by referencing by
[DatabaseObjectType]![ObjectName]![FieldName].
If the user is entering the State value from a Form, you'd reference:
[Forms]![FormName]![State]
where FormName is the name of your form, and State is actually the name of the Form control containing the State value.
If the user is entering the State value in a prompt from a query, you'd reference:
[Queries]![Query1]![State]
where Query1 is the name of your initial query that gets the state info from the user, and 'State' is the name of that field.
You put these references in to your secondary query or report:
for example, in a second query, you can set the State field Criteria (in query design view) to be = [Queries]![Query1]![State]
so the second query will pull the State value from the first query
on a report, similar idea - you can set the Control Source of the State control (in Properties) to be = [Queries]![Query1]![State]
I have a 2010 Access database that tracks volunteers for a charity group.
One of the columns in the VOLUNTEER table is called AVAILABILITY and the possible values are "seasonal" and "year-round".
I have created a report that lists out all the volunteer information, and it includes this column. The only problem I have is that I'd like to have the report abbreviate the values. Ideally "S" for seasonal and "YR" for year round in order to save space on the report. Is this possible?
Yes, of course. You can either do it in a query and base the report on that or in the report itself:
SELECT IIF([AVAILABILITY] = "Seasonal","S","Yr") As Avail
FROM MyTable
If you wish to set the control in your report, make sure to rename it to something other than Availability, say txtAvailability:
= IIF([AVAILABILITY] = "Seasonal","S","Yr")
You could use an IIF function, but this only allows for two availability options. To allow for more in the future I would create a second table to look-up the abbreviations that are going to be displayed in your report.
Copy and paste this into the SQL Editor in Access to create such a table:
SELECT "Seasonal" AS Availability, "S" AS Abbreviation INTO tblAvailabilityOptions;
You are then going to create a query that your report will be based on that combines your main table with the new table you just created, joining on the "Availability" column:
SELECT tblMain.ID, tblMain.Volunteer, tblMain.Availability, tblAvailabilityOptions.Abbreviation
FROM tblMain INNER JOIN tblAvailabilityOptions ON tblMain.Availability = tblAvailabilityOptions.Availability;
If you know how to use the combobox lookup feature on your main table, this will be even easier.
I'm working with this table and want to offer the user a Lookup list in one column. I can do this easy if I want to use a whole table.
But I want to show in this lookup just a subset of data.
Like this: SELECT ID, Name FROM Items WHERE Type = 'SomeType'
I have a query, but when I go into Lookup Wizard, I cannot select Queries. Why is this?
This is Sharepoint 2010, editing the Web Database in Access.
If you build a continues form then you would simply drop in a combo box control for one of the columns and then you can build your SQL as you have using the query builder.
For most access applications it really never was very practical to allow users to open and edit data by using tables directly anyway.
And for published web applications you not even allowed to do as such on the web side (so you can edit tables client side, but not web side in a browser).
Using a continues form here should work just fine. So drop in a combo box, build your query as you have. Set number of columns to 2 and bind this combo box to whatever the underlying column is that this first ID value is to be saved to, and you off to the races.