How to design textbox visibility expression in SSRS? - tsql

I have an RDL with a table/textbox visibility set to:
=iif(Fields!question_caption.Value = "OBJECTIVE 1",false,true)
I am trying to make this textbox display the value named "narrative" only if the question_caption record = "OBJECTIVE 1". How can I do this? Currently this textbox displays nothing with the above logic. I have the narrative field stored in a Placeholder if that makes any difference.
Here is some sample data for you:
create table #dummy_data
(
question_caption varchar(max),
narrative varchar(max)
)
insert #dummy_data values('1st week dates','week 1'),('2nd week dates','week 2'),('3rd week dates','week 3'),('OBJECTIVE 1','obj 1'),
('5th week dates','week 5')
select * from #dummy_data

I don't see anything wrong with your visibility expression. However, in your question, you're discussing two separate things as one (i.e., visibility & displaying a value in a placeholder).
The hidden property will show an object (tablix, textbox, image, chart, container, etc) if the expression returns false and will hide an object when the expression returns true. When I say hide, I mean that it will remove the object from the grid and, if all is setup properly, the surrounding objects will be shifted to fill the now empty space of the hidden object.
To display (or not) a value is an entirely different thing. To show or hide a value, you would put the following expression in the value property of the placeholder:
=IIF(Fields!question_caption.Value = "OBJECTIVE 1",Fields!narrative.Value,"")
Notice that I've set it up such that if the desired value of the question_caption field is present, it will display the value of the narrative field. Otherwise, it will return an empty string. This will maintain the layout of the report but simply display the desired value or an empty string, based on some criteria.
As for the issues you're current experiencing, I'm not sure why that would be happening. I would first check that you don't have a typo in the Objective 1 hardcoded value in your expression.
If this doesn't help, please comment and let me know some more information about your problem and I'll do my best to help.

Related

Visio - How to use the same shape property for many shapes

I have created one master shape with many properties. In the "Define Shape Data" windows of the master shape (of the document stencil), one of the properties (masterProp) is a variable list (so with a list of allowed values).
Is it possible to re-use the list of values allowed for this property (masterProp) to define the format of another property of type variable list in another master shape so that the list of values has to be maintained only once ?
Maybee is there a way to set up "lists" in Visio and link the expected/allowed values (format field) of a property to this list (without using excel) ?
Thanks for your advises,
Is it possible to use the same property (masterProp) in another master
shape to inherit the same allowed values? Or is it possible to link
the values of another property of type fixed list in another master
shape to the values of this masterProp property ?
You mean mastershape in document stencil or in external stencil ?
You can refer to some cell of mastershape in document stencil
To reference a cell of
Use this syntax
Example
A master
Masters[MasterName]!SheetName!CellReference
Masters[Gear]!Shaft!Geometry1.X1
About Cell References
Well, Thanks to #Surrodate, this is the correct way of doing this:
Add a user-defined cell in the ShapeSheet of the document (or the page)
Open the master shape for editing
In the master shape, open the shapesheet of the master shape and go to the section of the Shape Data
In the Format column, refer to your user-defined cell. Begin typing with a "=" otherwise it takes your entry as text (even if it recognise your data ...). To refer to the document, begin with =TheDoc!User... if your data are in the page, begin with ThePage!User... Do not forget to set the type of data to 1 or 4 (in case of list).
Ok, I found the shapeSheet of the Page-1. I added a user-defined
section, then a cell named "User.Softwares". I set the value to
="Soft1;Soft2;Soft3". Correct for list ? Then in the field "Format" of the "Define Shape Data" windows in have written
"Page-1!User.Softwares". Is that the correct way to refer to the
page-1 ? When I click on the property of a shape, it proposes the text
"Page-1!User.Softwares" and not the value of the user-defined cell in
Page-1 ... What is the mistake ?
You must also change Type field ! If in this cell stores 0, it mean "String". if cell value is 1 it mean Fixed list.
You must write Page-1!User.Softwares, without quotation marks !

MSAccess: Call a summation from a subform (in datasheet view) to be displayed in a textbox on the master form?

Sorry if this question is simple but I have googled and haven't found a satisfactory answer.
I'm creating an engineering cost estimator. I have a form that takes inputs as ISO/Drawing, and for each drawing number are many subforms where you can input ComponentDesc and should spit back out a TotalHours to complete number. I've included a picture (sorry for bad quality)
From the image, the table on the bottom is a subform in datasheet mode (which is usually hidden and located in the footer) which will calculate appropriate Total MH (manhours) for the ComponentDesc inputted into the subform on the right. I would like the small (and incomplete) textboxes to the left (below the title "MH Totals for ISO/Drawings") to display the aggregate total from the subform on the bottom.
I've been trying to use DSUM() to define Control Source for the textbox but it keeps coming back with #ERROR as seen in the textbox to the left. Right now what I have typed out is:
=DSum("[Total MH]","frm-PipingHandleMH")
in the expression builder. [Total MH] being my field and frm-PipingHandleMH being the subform on the bottom. I've tried to put brackets around everything but it didn't work (even though I'm not exactly sure what brackets usually do). Any advice?
DSum (and all domain aggregate functions) acts on a table or query. If you want to use that approach you need to refer to the source of that form and use a filter parameter to limit to appropriate records the I.E. if the form's datasource is qry-PipingHandles and if the form you are trying to sum on currently is showing handles for widget 4 then it would be something like:
=dsum("[Total MH]","qry-PipingHandles","[widgetID] = 4")
Note that if that 4 was the currrent state of form then you need to pass it in, so something like:
=dsum("[Total MH]","qry-PipingHandles","[widgetID] = " & [frm-PipingHandlesMH]![WidgetID].Value)
Where you reference the field in the form and append it onto the string that is applied as a filter to the source for Dsum.
Another approach is to put a subtotal in the footer of the form (iirc you don't actually need to show the footer) and then reference that footer control from the parent form.
Brackets are needed to demarcate names that include spaces or other odd characters, they also can be used (e.g. in query design view) to force Access to treat something as a name rather than a string literal.

Crystal Reports multiple parameter screens

I am creating a report with crystal reports 2008. My report has 4 parameters that the user must input, lets say: var1, var2, var3, var4. When I open the report it brings up the prompt to enter var1, once entered the user clicks next, and it goes to a second screen to get the next parameter, and so on.
My question is, is there a way to combine all of these to one screen. When the report opens, it has 4 drop downs for the parameters instead of one at a time?
I have thought about (and tried) a parameter that accepts multiple values but could not get it to work for my purposes. I am displaying approx 6 fields related to each parameter selected. SO if var1 is entered there will be 6 additional fields displayed. If it is not selected the area remains empty. Essentially each parameter represents a column to display in the report.
If there is a way to combine the 4 parameter screens that would be great, if you think this can be done using a multi value parameter then that is all I need to know and I will keep at it.
Thank you
Probably did not go about this in the best way but it serves its purpose and thought I would share for future reference. In response to the comments above, the parameters are not linked and I was not using a sub-report.
I ended up splitting the GroupSectionHEader into 4 parts, one for each variable. The report not contained GroupSectonHeader1-5. Each parameter variable had its own section. The user could select the parameter or False from the parameter input dialog. I then used the section expert and for each Group Header in the formula box nex to Suppress (No-Drill-Down) entered isnull({#var#}) or {var#} = " " this is because my variables are strings. This way if the user chose False, the variable would be left black and this formula would pick up on that and hide that section in the final formula.
I am very new at CR so I doubt my explanation is as clear as it could be, nor the most proficient.

Updating the selected dropbox item in a GUI

Currently I have a GUI in which once a 'Submit' button is pressed the drop menu which is left blank is then populated by a calculated value determined by the three other values.
I have successfully figured out how to grab all of the values using this logic:
temp=get(handles.FSTOPpopmenu,{'String','Value'});
fstop=temp{1}{temp{2}};
if (strcmp(fstop,'Select'))
fstop = 0;
else
fstop = str2num(fstop);
end
I just have two questions about this that I can not seem to find an answer for.
How would I go about updating the 'empty' drop menu to the calculated variable (the calculated variable will already be one of the possible values in the predetermined list)?
How would I go about presenting an error, say if I have an if statement checking that the amount of zeros in the array? Would a pop up box be sufficient?
Cheers.
As for your first question matlab's set command is what you're looking for. The documentation is here. You would probably need:
MyValueIndex = find(DropDownValues==NewValue);
switch handleToChange
case handles.handle1
set(handles.handle1,'Value',MyValueIndex);
case handles.handle2
set(handles.handle2,'Value',MyValueIndex);
otherwise
error('Uh oh!');
end
Note that MyValueIndex is the index of dropdown box values that you want. Which is found with a find command on the actual value.
Question two is more of an opinion question but I think that a pop-up box describing the problem is sufficient. Maybe add in a system beep for good measure!
Reference:
http://www.mathworks.com/matlabcentral/answers/22734-resetting-a-pop-up-menu-in-a-gui
http://www.mathworks.com/help/matlab/ref/find.html
http://www.mathworks.com/help/matlab/ref/switch.html
For a popupmenu uicontrol the Value property determines which element of the String property is currently being displayed. Get the String; compare its contents to the calculated variable to get the index; then set that index as the Value property. If the calculated variable is not currently in the String then add it to the String and then set the Value. (Note when comparing you need to compare numbers to numbers or string to strings, so you may need to do an appropriate data type conversion first).
Use an errordlg.

Reference Table to fill calendar form

In Access 2010, I've built a calendar Form that I want to be able to display who is off in a given month.
Each box of the calendar obviously represents a different day. I've got a table called "Separated" set up that ultimately stores the associate name and the date they are off -- one day per record.
Here's what I've done so far to try to test it on just one of the boxes (representing a day):
Private Function fillDays()
Dim rsNames As DAO.Recordset
Set rsNames = CurrentDb.OpenRecordset("SELECT * FROM Separated")
If Not rsNames.EOF Then
b0.Text = rsNames![Associate]
End If
Set rsNames = Nothing
End Function
I get the following debug note:
"Run-Time Error '2185"
"You can't reference a property or method for a control unless the control has the focus."
The debugger highlights the line with "b0.text = rsNames![Associate]
Is there some whay that I need to reference an index number from my "Separated" table?... or perhaps using a query method of some sort would be more effecient.
Assuming b0 is a textbox, the error you are getting is due to the fact that you can't use it's Text property when said textbox hasn't got the focus.
As stated in MSDN, «While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property is set to this new value. The Text property setting is then unavailable until the control gets the focus again» (emphasis mine).
Try using Value (help here) instead:
b0.Value = rsNames![Associate]