SSRS second parameter doesnot refresh after input first parameter - reporting-services

My SSRS report (2008 version) has two parameters. The first is a textbox receiving input for Supervisor' userid. The second is a drop-down list which depends on the first parameter to show the all the staff name working under the supervisor. After I input a supervisor userid for the first parameter, the second one does not refresh automatically. Then I press enter for the first parameter, an error message shows I have to select a value for the second parameter. My questions is how the second parameter can refresh automatically after I input the first parameter in the textbox.
Thank you very much for your help!

Are both your parameters as well as the Network_ID all INTEGERS?
It might work better if your first parameter was also based on a drop-down based on another dataset.
SELECT DISTINCT a2.Last_Name + ', ' + a2.First_Name AS Manager_Name, a2.Network_ID as Manager_ID
FROM Client_All c
INNER JOIN DimStaff d ON c.STF_NBR = D.ECMS_Wrkr_ID
INNER JOIN STAFF s ON s.STF_NBR = D.ECMS_Wrkr_ID
INNER JOIN ADPFile a ON s.FILE_NBR = CAST(a.FILE_NBR AS nvarchar)
INNER JOIN ADPFile a2 ON a2.Position_NBR = a.Supervisor_Position_NBR

Related

Update when unchecked value is checked

I have a query where the report name and report id are both displayed This only applies when the reports are pre-checked. The values are populated in a datagrid. If the report is unchecked, only the name is displayed. I tried using the UPDATE keyword but I kept running into syntax error. I know that the small change to the query is simple, but I am having a tricky time attempting to display the reportid when the report is unchecked or basically reportvisible being 0. How do I work around this to show the reportid regardless of if it is checked or not?
valsql1 = "SELECT c.ReportID, c.COMPANYID, rl.REPORTNAME
FROM CompanyReportListTable c
right join ReportList rl on c.reportid = rl.ReportID
and reportvisible = 1
and CompanyID =" & DropDownList1.SelectedValue & "
where rl.ReportID in (
Select ReportID
from ReportList
where ReportVisible = 1
)
order by ReportName"
You're right joining exclusively on reportvisible = 1, and then you're specifically selecting only reportIDs with reportvisible = 1. You are twice-over filtering out rows with reportvisible = 0, so of course you aren't going to get reportids for those rows. You should add rl.reportvisible to the SELECT clause and remove reportvisible = 1 from the join and where clauses.
It is only a one word/two letter change. At the first SELECT statement, instead of c.ReportID, it should be rl.REPORTID. Refer back to the right join; y using a right join, it returns the selected rows from reportlist, matches it with crl table. Now we made it so reportID appears regardless if it matches or not. Kind of like report name/title

How to Add User Input Criterion to an Access Inner Joined Crosstab Query

Prompting for user input parameters in an Access query is fairly straight forward. Go to design view and under criteria, just put [Your Text:] -- and when the query runs the user is prompted for the field criteria.
Unfortunately when I try this with my Inner Joined Crosstab query I get the error:
The Microsoft Access engine does not recognize the '[Your Text:]' as a
valid field name or expression.
I know the inner join crosstab still allows for criteria, as hardcorded criterion works.
To give you a better idea of what I'm looking at, here is the SQL code.
DOESN'T WORK:
SELECT *
FROM ([CrossTabQ1]
INNER JOIN [CrossTabQ2] ON [CrossTabQ1].[Month] = [CrossTabQ2].[Month])
INNER JOIN [Query3] ON [CrossTabQ1].[Month] = [Query3].[Month]
WHERE ((([CrossTabQ1].[Month])= [Enter Month, in YYYY-MM Format:]))
ORDER BY [CrossTabQ1].[Month];
DOES WORK:
WHERE ((([CrossTabQ1].[Month])="2015-12"))
ORDER BY [CrossTabQ1].[Month];
Any tips regarding why I'm getting this error and how I can accept user input criterion would be greatly appreciated!
Try:
PARAMETERS Enter_Month Text ( 255 );
SELECT *
FROM ([CrossTabQ1]
INNER JOIN [CrossTabQ2] ON [CrossTabQ1].[Month] = [CrossTabQ2].[Month])
INNER JOIN [Query3] ON [CrossTabQ1].[Month] = [Query3].[Month]
WHERE ((([CrossTabQ1].[Month])=[Enter_Month]))
ORDER BY [CrossTabQ1].[Month];

Return text if tablix results are empty

I have a tablix that is linked to DataSet1.
DataSet1 uses the following TSQL code
select ir.SourceRef as Account_Ref,
rab.BalanceFromDate,
rab.ClosingBalance Current_Balance,
ra.Account_ID as rserial,
ra.Current_Balance as Current_Balance
from db1..RentAccountBalance rab
left join db1..ImportReference ir on ir.EntityID = rab.AccountId and ir.EntityType='XXXX.XXX.X.XX'
left join db2..RentAccounts ra on convert(varchar(50),ra.Account_ID) = ir.SourceRef
where ir.SourceRef = '12857'
order by rab.AccountBalanceId
As I know that there is no ir.SourceRef that is equal to 12857, the result set is blank. Therefore, my tablix comes back just blank.Is there a way that if no results are returned that a text of say "All Accounts are OK." be displayed by the report instead?
Hope that's clear?
Thanks
You can try expression like:
=IIF(IsNothing(Fields!FieldName.Value, "Accounts are OK", Fields!FieldName.Value))
Or if you want to check if there is no data at all, you can try to throw an error in TSQL in following:
--add this line to the end of query:
IF ##ROWCOUNT = 0 RAISERROR('Accounts are OK', 16, 1)
If you use a Stored Procedure you can then insert your Select statement data into a table variable before returning it. From this you can perform a check on its contents before it is returned to the report.
For example if you populate a table of data you wish to return as follows
INSERT INTO #ReturnTable (Account_Ref, ...)
SELECT ir.SourceRef, ...
You can then query it's contents by using a command such as
IF (SELECT COUNT(*) FROM #ReturnTable) = 0
BEGIN
INSERT INTO #ReturnTable (Account_Ref, ...)
SELECT 'All Accounts are OK', ...
END
You can then perform a check within the report to see if the Account_Ref is 'All Accounts are OK', and if so display the report appropriately. You can even set the entire report's contents inside a rectangle with the visibility set to the result of
=iif(First(Fields!Account_Ref.Value) = "All Accounts are OK", false, true)
You can layer another object (an information message perhaps) on top of this with the inverse of this visibility set.

Access 2010 - Enter parameter value on report but not in query

I'm using Access 2010 and create a string filter on the fly by pulling information from the user via various controls on a subform. I then use the filter in one of two ways:
I set the recordsource of another subform in datasheet view
Forms![frmCentral]![TrainingEventsSubform].Form.RecordSource =
gstrTrainingEventsFormFilter
Or I use it as the query parameter of openreport
DoCmd.OpenReport "rptTrainingEvents", acViewPreview, gstrTrainingEventsFormFilter
I don't understand why, but the query string works fine when setting the recordsource, but the exact same string will result in an Enter Parameter Value box appearing when issuing the openreport command. Further, the query works perfectly if I paste it into the report's recordsource parameter.
As an example, here's a string that's built:
SELECT TrainingEvents.StartDate, TrainingEvents.EndDate, ClassList.ClassNumber, [Users].[FirstName] & ' ' & [Users].[LastName] AS Trainer, TrainingLocations.TrainingLocationName, EventVenues.EventVenueName, TrainingEventStatus.TrainingEventStatus, TrainingEvents.TrainingEventID
FROM Users INNER JOIN (TrainingLocations INNER JOIN (TrainingEventStatus INNER JOIN (EventVenues INNER JOIN (ClassList INNER JOIN TrainingEvents ON ClassList.ClassID = TrainingEvents.ClassID) ON EventVenues.EventVenueID = TrainingEvents.EventVenueID) ON TrainingEventStatus.TrainingEventStatusID = TrainingEvents.EventStatusID) ON TrainingLocations.TrainingLocationID = TrainingEvents.TrainingLocationID) ON Users.UserID = TrainingEvents.TrainerID
WHERE (TrainingEvents.StartDate >= #1/1/2014#) AND (TrainingEvents.EndDate <= #12/31/2014#) AND (Users.UserID = 10)
ORDER BY TrainingEvents.StartDate;
The Enter Parameter Value box appears with Users.UserID.
It's obviously something with userid, but for the life of me I can't understand what!
Any suggestions?

Allowing Optional Parameters for MySQL Query

I have a search page that has multiple fields that are used to create a refined search. Every field is optional. I'm trying to start crafting my sql query so that it will work given the proper variables but I'm having trouble.
Here is the SQL query I currently have:
SELECT
indicator.indid,
indicator.indicator,
indtype.indtype,
provider.provider,
report.report,
actor.actor
FROM
actor,
indicator,
indtype,
report,
provider
WHERE
indicator.indtypeid = indtype.indtypeid
AND indicator.actorid = actor.actorid
AND indicator.reportid = report.reportid
AND report.providerid = provider.providerid
AND indicator.indicator LIKE '%$indicator%'
AND indicator.indtypeid = $indtypeid;
Whenever I provide an indicator and an indtypeid, the search works just fine. However, when I leave the indtypeid field blank, and have the variable set to * (as its default value), the query returns no results. I've tried playing with the query manually and it doesn't seem to like the * or a % sign. Basically, if only an indicator is specified and no indtypeid is specified, I want to return all indicators for all indtypeids.
I'm sure I'm missing something minor, but I would appreciate any assistance that could be provided. I may be going about this all wrong in the first place.
Try this instead:
SELECT i.indid, i.indicator, it.indtype,
p.provider, r.report, a.actor
FROM actor a
INNER JOIN indicator i ON a.actorid = i.actorid
INNER JOIN indtype it ON i.indtypeid = it.indtypeid
INNER JOIN report r ON i.reportid = r.reportid
INNER JOIN provider p ON r.providerid = p.providerid
WHERE 1 = 1
AND ($indicator IS NULL OR i.indicator LIKE '%$indicator%')
AND ($indtypeid IS NULL OR i.indtypeid = $indtypeid);
So if you pass a $indicator = NULL, then the first condition AND ($indicator IS NULL OR i.indicator LIKE '%$indicator%') will be ignored since it will resolve to True, and the same thing for the second condition.
I've removed other Where condition and replace them with JOINs, and for WHERE 1 = 1 to make the query work fine in case you pass the two variables $indicator and $indtypeid with NULL values for each, in this case it will return all results since 1 = 1 always true.