I have a subreport that will search a table pulling all matches depending on two things. 1.) Some filtering criteria in the command for the subreport and 2.)it will search based on the criteria pulled by a parameter from the main report.
1.) Is this possible? I have tried for a few days now to get this to work but I feel I am missing something. I cannot get the field in the main report to pass the information to the parameter for the command in the subreport.
Here is the command for the subreport.....
DECLARE #DIE VARCHAR (20)
SET #DIE = '1315240018'
SELECT DISTINCT BCKUPDIE.TOOL1
FROM FS11HD AS BCKUPDIE
JOIN FS11HD AS ORGDIE
ON
BCKUPDIE.DIE_SHAPE = ORGDIE.DIE_SHAPE
AND BCKUPDIE.AROUND1 = ORGDIE.AROUND1
AND BCKUPDIE.ACROSS1 = ORGDIE.ACROSS1
WHERE ORGDIE.TOOL1 = #DIE
When run in sql it will give me any TOOL1 rows that have matching criteria. This is what I want my subreport to, am I going about this the wrong way?
We have an old version of Crystal report (XI) but the logic might be the same with your version.
On the menu select [Edit] [Subreport Links].
Select the sub report from the pick list then map your select choices to the sub reports selection criteria.
On the sub report you will have to have parameter fields that will match the values up with the values you wish to pass. Such as if you select date as a selection criteria on the main report and you want the sub report to also filter by this date create a date pram in the sub report. By linking all the select criteria with [linked] values it will behave as a straight through pass of the parameters without a prompt box being all have been answered via the linkage between documents.
I feel you took difficult path to achive your requirement, Try below solution I hope this will be easy to implement.
Firstly remove the #Die from command instead pass the #Die value from main report as part of formula field.
your subreport query will be changed to
SELECT DISTINCT BCKUPDIE.TOOL1
FROM FS11HD AS BCKUPDIE
JOIN FS11HD AS ORGDIE
ON
BCKUPDIE.DIE_SHAPE = ORGDIE.DIE_SHAPE
AND BCKUPDIE.AROUND1 = ORGDIE.AROUND1
AND BCKUPDIE.ACROSS1 = ORGDIE.ACROSS1
In main report create a formula #Die and enter data as '1315240018'.
Now link main report and sub report and in linking pass the #Die formula and your main report parameter to sub report, By this you have these as parameters in sub report.
In record selection of sub report write as below.
ORGDIE.TOOL1 = ?Die //value passed from main report
and your parameter linking
By this your filtering criteria will be added to the sub report query.
This should work let me know incase any error
Related
I have read some other posts about this problem, but couldn't get it to work unfortunately.
I have 2 SSRS reports. The first report take a multiple string parameters, runs a select query, and present some rows. Then I have a "Go to Report" Action that pass the values to a sub report and run an update query to update the rows.
When passing the multiple value parameter to another report I used
=join(Parameters!ponum.Value,",") but the sub report only recognize the parameter as 1 value. The parameter on the sub report has set to allow multiple value already.
The type of values I want to pass is like 'a-01', 'b-02', 'd01-293'. However, when passed to another report the parameter becomes a-01, b-02, d01-293
I tried to pass with = "'" + join(Parameters!ponum.Value,"','") + "'" but still fails.
Is there any other ways I can do this?
Thanks
If your subreport's parameter is multi-value like your main report parameter then in the subreport properties all you do is set the parameter value to your main report's parameter.
So if we have MainReport with a parameter called PoNum and it is multi-value. Then we have mySubReport with a parameter of subPONums for example then in the subreport placeholder in the main report, set the parameter value to [#PoNum]
The entire parameter object will be passed to the subreport.
I have an Access Form with various dropdowns. The form contains a report in a subform. The report is based on the following SQL statement which references the dropdowns on the main form:
SELECT imp_rule_CURRENT.target
,imp_rule_CURRENT.Phase
,imp_phase.SortOrder
,imp_rule_CURRENT.Solicitation
,imp_rule_CURRENT.Qualification
,imp_rule_CURRENT.Activity
,imp_rule_CURRENT.ClientLocation
,imp_rule_CURRENT.ProviderLocation
,imp_rule_CURRENT.Answer
,imp_rule_CURRENT.Comment
,imp_ActivityList_Test_PB_MetaversionC2.HeadingText
,imp_answer.full_name
,imp_answer.icon2
,imp_phase.Chapter
,tbl_Country.short_name
,IIf([Forms]![frm_ClientModel]![ckbYesOnly], InStr([Answer], "is_yes") > 0, - 1) AS Is_Yes
FROM imp_phase
INNER JOIN (
imp_answer INNER JOIN (
tbl_Country INNER JOIN (
imp_ActivityList_Test_PB_MetaversionC2 INNER JOIN imp_rule_CURRENT
ON imp_ActivityList_Test_PB_MetaversionC2.SignatureTagSet = imp_rule_CURRENT.Activity
) ON tbl_Country.ISO_Country = imp_rule_CURRENT.target
) ON imp_answer.code_name = imp_rule_CURRENT.Answer
) ON imp_phase.code_name = imp_rule_CURRENT.Phase
WHERE (
((imp_rule_CURRENT.target) = [Forms]![frm_ClientModel]![cmbCountry])
AND ((imp_rule_CURRENT.Phase)
LIKE IIf([Forms]![frm_ClientModel]![cmbPhase] = "ALL", "*", [Forms]![frm_ClientModel]![cmbPhase]))
AND ((imp_rule_CURRENT.Solicitation) = [Forms]![frm_ClientModel]![txt_Initiative])
AND ((imp_rule_CURRENT.Qualification) = [Forms]![frm_ClientModel]![txt_Qualification])
AND ((imp_rule_CURRENT.ClientLocation) = [Forms]![frm_ClientModel]![txt_MeetingLocation_Client])
AND ((imp_rule_CURRENT.ProviderLocation) = [Forms]![frm_ClientModel]![txt_MeetingLocation_Bank])
AND ((imp_rule_CURRENT.Answer) <> "is_not_applicable")
AND ((IIf([Forms]![frm_ClientModel]![ckbYesOnly], InStr([Answer], "is_yes") > 0, - 1)) = True)
)
ORDER BY imp_phase.SortOrder;
When I have form open and the following part of the SQL statement evaluates to True Like IIf([Forms]![frm_ClientModel]![cmbPhase]="ALL","*",[Forms]![frm_ClientModel]![cmbPhase])) the query, when opened manually, shows all results as I would expect. Yet the subform which is based on this query shows no results.
Question: Why does the subform not show any results and how can I get the subform to show them?
Update 2:
I have tested and found out that if I view the report upon which the subform is based, then the correct results show. As noted in a comment below, the subform report works as intended when I selected anything other than "ALL". Results are shown for every other item seleted in the subform, just not when I select the option "ALL". Those results are not shown in the subquery, yet oddly they do show if I open the report manualy. So perhaps the problem is somehow linked to the subform?
I still don't understand why this is the case, but the answer to my problem was that the query of the mainform had to be adjusted to include the new statement. despite the subform NOT being linked to the main form.
As noted in my update, when I opened the query manually it worked fine. When I opened the report that was based on the query it worked fine. Only when I tried to open the report through the subform did it not show the expected result.
This finally led me to the insight that perhaps, under certain circumstances, the record set that was being shown was restricted somehow.
The main form that I had set up was itself based on a query. I had not updated that query to contain the new Like IIf([Forms]![frm_ClientModel]![cmbPhase]="ALL","*",[Forms]![frm_ClientModel]![cmbPhase])) command. Despite my subform NOT being linked to the main one, it restricted the recordset available to display.
Are you re-querying the subreport after the update?
Your code should include something along these lines, where rvSubReportView is the sub-report object:
rvSubReportView.Report.Requery
This would be in the AfterUpdate() function for the main form's ComboBox control.
I have a main report that pulls data from our CRM datasource:
-Project No
-Voucher No
-Cheque No
Then I have a subreport that is from a different GP datasource and displays
-Cheque No
These are linked on Voucher No.
The subreport works great, however I need a way to change the font colour if the Subreport "Cheque No" and the Main Report "Cheque No" do not match.
Can I use an expression to check that they match?
Note: I have tried to use two separate datasets within the same report and use a lookup to pull in the cheque number from GP, however it gives me #error, and I am not sure why.
You can simply add a parameter to you sub report. That would be evaluated at the SSRS level and appropriate with in the SR.
Yes you can do this by Using Expression in SSRS Report.
your sub report is linked on [voucher no] you need add one more parameter in your sub report [ChequeNo] and pass it from your main report .
Now you have to right click on your textbox property select Font Select color and Expression of Color
=IIF(Parameters!ChequeNo.Value<>Fields!ChequeNo.Value ,"Red","Black")
I'm trying to generate a report off of a form with combo/list boxes that will filter the report parameters. I'm doing this for several forms/reports, but generally need the same thing for all.
For example, I have a form for my programs which has a combo box "cboYear" to select a year, based off of [progdate] and formatted as "yyyy" so the user can select what year they want their reports from. But, I also have a cascaded combo box "cboProgramTitle" that is based off of the [progdate] box, and only shows programs selected for the "cboYear". The code below will run the report and filter if something is selected for "cboProgramTitle", or returns all if left blank. How do I also get it to return all programs for the "cboyear", since this is already a 'formatted' version of [progdate], if a year is selected, but "cboProgramTitle" is left blank?
[CODE]Private Sub cmdAttendees_Click()
If IsNull(Me.cboProgramTitle) Then
DoCmd.OpenReport "rptProgramAttendees", acViewReport
Else
DoCmd.OpenReport "rptProgramAttendees", acViewReport, , "ProgramIDFK = " & cboProgramTitle & ""
End If
End Sub[/CODE]
I've run into this same problem with similar forms/reports, too. Need help filtering reports off multiple combo/list boxes, with one of them being the year list, or others being month or quarter lists.
I'm what I call a 'novice frankensteiner,' in that I can piecemeal code together, but can't really write it from scratch. :)
Thanks in advance!
I have a subform which could be different depending on a user choice (as they are make table queries). Consequently I have had to store the actual table name in a variable caled MyResultSO. This works fine and returns the correct table name. I am then trying to get the value of a field from the subform. I am then trying to combine the variable with the field name.text to get the value of the field from the subform but can't get the syntax correct.
I have tried variations but, for example here is one:
MyResultSO = Me.RESULTS.SourceObject
'this works fine and returns "Table.POWER PRICES Query Table 3"
MyProductCode = MyResultSO & !PRODUCT_CODE.Text
'which is where I am trying to combine the value of variable MyResultSO and the field which is PRODUCT_CODE.Text.
Combined this should return the value of the current record from the following:
Table.POWER PRICES Query Table 3!PRODUCT_CODE.Text.
As you will probably tell from the above, I am not very experienced with VB.
Somewhere in the private module of the main form, here Me:
MyResultSO = Me.RESULTS.SourceObject
MyProductCode = Me.RESULTS.Form.Controls("PRODUCT_CODE").Value
Not to use .Text, that requires .Focus: so is bad, it does not always work!
MyProductCode = Me.RESULTS.Form.Controls("PRODUCT_CODE").Text ' <= it's bad.
Here PRODUCT_CODE is the name of a control on the subform named "Table.POWER PRICES Query Table 3".