Displaying table with different fields depending on clicked textbox in SSRS - reporting-services

I have two Textboxes with some calculated values. Table is initially hided. When I click TextBox1 I want to display fields Field1, Field2, Field3 in Table, when I click TextBox2 I want to display fields Field4, Field5, Field6 in Table. Is it possible to do so?
I've tried to make visible table by "Display can be toggled by this report item" checkbox in Tablix properties and putting there one of the textboxes, but that wouldn't work for second Textbox to display different fields.

You can set the Visibility of a row so you can have one row with your first set of data and then an additional row below.
I would use a Parameter to hold the value of what to show and then set the visibility for the row based on the parameter value.
=IIF(Parameters!TABLE.Value = "Table A", TRUE, FALSE)
The other row would be the opposite.
OR
You could add 3 calculated fields to the Dataset to switch the values based on the parameter.
=IIF(Parameters!TABLE.Value = "Table A", Fields!Field1.Value, Fields!Field4.Value)
Then your report would just reference the calculated fields.
With either method, you can set an Action on TextBox1 to Go To Report to open the same report but with the changed parameter value.

Related

MS Access: Why is my combo box displaying the wrong value?

I have 2 columns that populate my combo box. They come from a table where I manually wrote in an ID and a clean_value field.
The goal:
Display both columns on a combo box on a form. The ID values should be on the left of the clean_value values when looking at the drop down list. When selecting something in the list, the combo box should display the clean_value, not the ID. When saving the form, the form should write the ID value to a different table.
What I've tried:
I set up the table to get the values from. I set up the combo box to show the 2 values in the correct orientation. The ID value is the value that is being written to the table.
The problem: When the user selects one of the values in the list, their selection shows the ID. I want to display the clean_value upon selection instead. How do I do this?
I found a way to do this. I grabbed the clean_value field, the ID field, then the clean_value field again in the row source, then I just set the width of the first clean_value field to 0.021".

Referencing list boxes in Access

I'm new to Access so this might be a simple question.
I have a form in Access 2013. There is a subform displaying a table from an SQL server, like so.
Company Product
-----------------
CompanyA Product1
CompanyA Product2
CompanyB Product1
CompanyB Product2
Using ListIndex in a list box, I can display the index of any row I click on. For example if I click on the second row (CompanyA, Product2) the list box shows a ListIndex of 1. If I click on the third row the ListIndex is 2.
How do I get a list box to display the value of a column instead of the ListIndex?
What I am trying to do is that, when I click on a row in the subform, I'd like to display each column value for that row in its own list box.
However, I cannot seem to use ListIndex as a variable in a larger function. I've attempted the following:
Typing only the column name into the list box. Does not update the value if I click on a different row.
Column property does not update the value if I click on a different row.
Controls property gives an error.
Value property displays the correct row but only works for the first column.
Combo boxes circle back to the problem that I need to use ListIndex as a variable.
Is there a different property I should be using? Am I missing something in the properties I tried?
There seems to be a little confusion with terminology. Your List3 is a list box, not a subform.
The fields Company and Product look like text boxes, but if the first one has the control source =[List3].[ListIndex], and shows a text and not a number, it seems to be a listbox with height = one line.
I suggest using text boxes for Company and Product, with these control sources:
=[List3]
for the bound column. Alternatively, for consistency: =[List3].Column(0)
=[List3].Column(1)
for the second column.
These text boxes update themselves automatically when you click on an item in the listbox.
To get the value of a listbox, and if you allow multi-select, use the following example:
For Each varItem In Me.lstHierarchy.ItemsSelected ' Loop through the items selected (if multi-select allowed)
strPrint = ""
For i = 0 To iCols ' Loop thru each column in a row
strPrint = strPrint & "|" & Me.lstHierarchy.Column(i, varItem)
Next i
Debug.Print "Selected Value: " & strPrint ' Display the row; columns are delimited with '|'
Next

MS ACCESS Multiple Record Visibility If Statement

I am building a form in Access 2013 and I will print out 4 fields for each record.
So Let's say the form processes 2 records it will print out:
Field 1 Field 2 Field 3 Field 4
Field 1 Field 2 Field 3 Field 4
Now I want to have it when it displays Other to print out the description of the other from a table. To do this I want the field named DefectType to go invisible and then the Other field to become visible. I start with Other being invisible and DefectType Visible and place them on top of each other. Here is the VBA:
If DefectType <> "Other" Then
DefectType.Visible = True
Other.Visible = False
Else
DefectType.Visible = False
Other.Visible = True
End If
It works fine if they are all other because what it does it takes the first record value of Other and applies it to all the other records for that field.
So if the first record that is displayed has a field 3 and it has a value of Other it will then look for the value in the table that is under the "other" field and display the content. SO lets say the "other" content was lamination. Instead of showing Other it will make that DefectType field invisible and show the "Other" field which will show Lamination.
The problem is it then does this for the rest of the records. It won't test to see if the field 3 is "Other" or not, it will just assume and then put it's "Other" field contents for the subsequent records. This means that since some actually already have values in them, like Corrosion, and nothing in the "other" field it will display a blank box.
I want it to test each field 3 as it is displayed so it can tell if "other" is in the field or not.
I'm unsure how well I understand your question, but it sounds to me that your form includes 2 text boxes named DefectType and Other. When the value of DefectType is "Other", you want to display the value from the Other text box. But when the value of DefectType is anything else, you want to display the value of DefectType.
If that is correct, you can create a new text box named txtSummary and use this as its Control Source property.
=IIf([DefectType] = "Other", [Other], [DefectType])
The txtSummary text box would not be editable. To change its value, you would change the values in DefectType and/or Other.
That approach will ensure txtSummary is always updated based on the current values of DefectType and Other in the same record. And it will do that for each record in the form, including when the form is in Continuous Form or DataSheet View.
Your original approach would do what I think you want only when the form is in Single Form view.

One combo box for two queries Access

I have a form that needs to use two combo boxes but the values in the second combo should come from two different tables based on the first combo selection. If I select option A in combo_1 I want to list all the agency names from tblRefAgency in combo_2. If I select option B in combo_1 I want to list all of the carriers from tblrefCarrier in combo_2. I can add VB code to hide/show two different combo boxes and then overlap them, but I feel I should be able to do this in a query. Thoughts?
As long as you are dealing with a single form, you can easily set the row source of the second combo in the After Update event of the first combo.
If Me.Combo1=1 Then
Me.combo2.RowSource = "SELECT ID, Description FROM tblRefAgency
End If
If the 2nd combo is bound to a field, you will also have to set the combo in the current event to ensure that data is displayed properly.

Hide Column based up Parameter Selected SSRS

I would like to set the visibility of columns based upon the value selected in a parameter.
The problem is I do not want a specific parameter to do this (i.e Hide column X True/False)
My report has several different "departments" who are only interested in certain columns.
What would be the syntax for example to hide the "Sales" column when the "Customer Care" parameter is set?
you can do these works step by step:
1- press right click of your mouse in your favorite column
2- select column visibility
3- from opened window select "Show or hide based on an expression" radio button
4- set an expression for hidden state. for example:
=IIF(Parameters!CustomerCare.Value <> "favorite value", true,false)