In Livecycle forms make all negative values red - pdf

I'm building a form in Adobe Livecycle and would like all negative numbers to display in red. I can accomplish that on individual elements by attaching this code to the exit event:
form1.#subform[0].Table3[0].HeaderRow.concessions1::exit - (FormCalc, client)
if ($.rawValue <0) then
$.font.fill.color.value = "255,0,0"
else
$.font.fill.color.value = "0,0,0"
endif
Currently I have to add this code to every single field, is there a way to make this script run on multiple fields without retyping it for each one?
Thanks

your options are:
Externalize the code in a script object and call the method on the exit event. You can pass the field as an input parameter so that your code is generic.
If you want to do this before a form is submitted, you can create a method that loops through your form fields and reference this code to highlight the negative values.
I hope this helps. Let me know if you have any more questions.
Thanks,
Armaghan.

Related

Spotfire: Need to select all values in a Multi select List Box Document Property

I have zero knowledge of coding. Can someone please help me with code.
My situation is as follows:
Dashboard has a Multi select List Box (Document Property). I am using that to restrict the data and calculations.
User does not want to select values each time. He wants a button where in (s)he click it once and all the values present in the list box gets selected.
Can someone please help me.
Regards,
Subro
This is fairly easy to do. Let us say that the Document Property that the list box is used for is named "Test" and it is of type "String List". Then you can use an IronPython script like so:
Document.Properties["Test"] = ["First Choice","Second Choice","Third Choice"]
Where the string list you see above, are all the values in your list box. Make sure that the strings you assign to the document property are the ones you want to populate your list with, since sometimes the displayed values can be different than the ones assigned to the document property(The case of using the "Fixed Values" option when setting up the control).
Hope that this helps.
Zenios

How to use custom code to add Excel-like "color scale" conditional formatting to SSRS report

I am trying to use this custom code in SSRS
public function ColorScaleRYG(value, minValue, maxValue) as string
in a custom code in ssrs
and then in a Fill expression
=Code.ColorScaleRYG(Sum(Fields!SalesAmount.Value), 0, 100000)
which should break my values in a group and assign shades of colors from red(0) to green(max valer).
But for some reason nothing happens/
What am I missing?
I need something like that:
I wont be able to give you the specific answer as it is with your code, however this is how I go about it.
In Design Mode I Right click the required Cell and Select "Text Box Properties.
I then go to the Fill Tab and click on the expression button next to Fill Color.
I then User something like the following code
=IIF(Fields!Total_Eligible.Value>100,"MidnightBlue","Silver")
You should be able to Stack this IIF Commands.
It is just a matter of changing the Fields! field to the approriate variable and then the conditions.
This Returns the following Values
Hope this Helps.
Post Note - Probably dont use these colors as they aren't easy to read , I just grabbed two at random off an existing report to demonstrate.

VB.Net ComboBox (as Dropdown) not translating text to DisplayMember with Databinding

I inherited a fairly large project at work that is undocumented and written in VB (originally started pre .NET, ended around .NET 2). I'm in the process of updating / refreshing a lot of the code, but have run into an annoying issue that I haven't found the solution for yet. This system utilizes a UI, a Web Service, and a SQL DB.
Problem: I have a Databound Combobox (originally set to DropDownList - I'm changing it to DropDown, which is what started this mess - going back isn't an option) that is tied to a DataSet that comes from a Web Service. When a user types in the item they want manually, the data from the text field doesn't seem to associate itself with the DisplayMember, which forces the WS/SQL query to fail (it is sent a blank value when it's expecting a ValueMember). If the user types in a partial selection and then chooses the value they want from the DisplayMember list using the arrow keys or tab, the query goes off without a problem.
My Question: How do I get the text field to translate to the DisplayMember which will then properly tie itself to the ValueMember which will then allow the query to execute correctly? Sorry for making this sound complicated or convoluted; I'm sure the answer is easy and I'm just glazing over it.
The relevant bit of code is:
With cmbDID
If dtsLU.Tables.Contains(reqTable) = True Then
.DataSource = dtsLU.Tables(reqTable)
.DisplayMember = "zip"
.ValueMember = "gridID"
End If
End With
cmbDID.DataBindings.Clear()
cmbDID.DataBindings.Add("SelectedValue", dtsData, strDT & ".gridID")
I've tried changing "SelectedValue" to "Text", which almost works - but it directly translates to gridID and skips zip which ends up with an incorrect Web Service response since the zip and gridID field values are not synced (zip (DisplayMember) may be 5123 while gridID (ValueMember) may be 6047). I've tried changing "SelectedValue" to "SelectedIndex", and that got me no where.
Any help is greatly appreciated.
EDIT
To add some clarification to the process, the below pseudo code / description is roughly what happens. I could post the whole module, but I feel that would just muddy the whole question even more.
Private Sub A
FormAlpha is created with 1 ComboBox in the form of a DropDown
This DropDown is populated with a DataSet
DataBinding with a blank DataSet is added to the control to keep track of the users input
End Sub
lblSubmit_Click event is triggered on FormAlpha by the user after they have populated the DropDown with their data. lblSubmit_Click calls Private Sub Submit
Private Sub Submit
BindingContext(DropDown DataSet, tableName).EndCurrentEdit() is called
DataSet.HasChanges() is processed
If changes are present, changes are processed
HERE lies the problem
If the user has manually typed in the DropDown field, but not hit an arrow key or tab, then the DataSet registers a change, but returns a null value in all fields - it knows something was entered, but that data apparently didn't pass through the DataSet for the ComboBox (ListItems or SelectedIndex didn't change / fire I'm guessing). If the user selects the item with the arrow keys, the DataSet has the proper input (I'm assuming the Data was validated by the control at this point).
If the processed data is good, a value is entered into the database
If the processed data is bad (empty), an error is returned
End Sub
If the above can't be solved with what I've provided, but someone still knows a better way to handle this type of situation, I'm all ears. Rewriting the module isn't ideal, but fixing this problem is a necessity.
Alright, while this fix may not be ideal, it is a fix none the less.
The bare bones problem was that the text value of the DropDown wasn't causing the data to actually affect the SelectedIndex / SelectedValue of the control unless you interacted with it using the arrow keys or a mouse click. So, while the DropDown would read "1234", in reality the control saw "".
The fix I have in place for this is simply calling comboBox.text = comboBox.text whenever the user hits the submit button.

MS Word ActiveX Textbox Spell Check

I am working on a MS Word form for a client where they want the ability to count the number of words, check spelling, have a character limit, and have the rest of the form locked down so that the end user cannot change anything they are not supposed to. I have attempted to convince them that word count and character limit are redundant if we have proper instructions, however, this is what they want. They also want the form to be able to "work" even if the user does not enable macros, meaning, they want it locked and a character limit first and foremost.
I know that if we just rich text content controls and put the form into a group spell check and word count word while also "locking" the remainder of the form, except user content controls do not allow for character limits and using legacy/activex controls in a grouped form locks those controls as well.
So, for now, I have settled on using the ActiveX Textbox (this is negotiable if I have a reason to use the legacy textbox) and have achieved the minimum "workability" (if that's even a word). The only way I have figured out to check the spelling is below:
Sub chkSpelling()
Activedocument.Tables(1).Rows(26).Cells(1).Range.Text = txtRole.Text
Activedocument.Tables(1).Rows(26).Cells(1).Range.checkSpelling
txtRole.Text = Activedocument.Tables(1).Rows(26).Cells(1).Range.Text
'... so on and so forth throughout each text box
End Sub
The issue is that this is not good enough for my standards. Printing the text of each textbox (up to 1700 characters) at the bottom of the screen each time I need to check the Spelling is unacceptable. Does anyone else have any ideas?
Thank you for your assistance.
Answer with help from #bibadia
Dim doc As Document
Set doc = Documents.Add(, , wdNewBlankDocument, False)
doc.Paragraphs(1).Range.Text = txtRole.Text
doc.Paragraphs(1).Range.CheckSpelling
txtRole.Text = Replace(doc.Paragraphs(1).Range.Text, Chr(13), "")
Use CreateObject to create a new word instance
Ensure .Visible = False (I think that is the default)
Create a new document in that instance.
Copy the text to be checked into that
Spell check.
Remove the document and the Word instance.
If I understand your question correctly then,
I need to check the Spelling is unacceptable. Does anyone else have any ideas?
If text boxes are named with numbers, you might be able to use loop, and save your coding lines with time.
want the form to be able to "work" even if the user does not enable macros
If user did not enable macros, he would not be able to see form (is it User Form, you want to say) and no background macro code would run. (Tested on Ms-Excel 2007), ultimately failing all.
regarding text box control on user form
yes that can be set to character limit from properties menu, and spell check can be done using your method.
Set range2 = Documents("MyDocument.doc").Sections(2).Range
range2.CheckSpelling IgnoreUpperCase:=False, _
CustomDictionary:="MyWork.Dic", _
CustomDictionary2:="MyTechnical.Dic"

Gray out a form row's (detail's) button conditionally with VBA code

I have a standard form in MS-Access which lists a bunch of orders, and each row contains order no, customer, etc fields + a button to view notes and attached document files.
On request from our customer we should gray out the button btnAnm (or check or uncheck a checkbox) depending on a calculation from two queries to two other tables (a SELECT COUNT WHERE and a check if a text field is empty).
I've tried btnAnm_BeforeUpdate(...) and btnAnm_BeforeRender(...) and put breakpoints in the subs, but none of them trigger. The same if I use the control Ordernr instead of btnAnm.
I'd like a function in the Detail VBA code to be triggered for each "Me." (row) so to speak, and set the row's control's properties in that sub.
What do I do? I've looked at the help file and searched here.
*Edit: So I want to do something that "isn't made to work that way"? Ie. events are not triggered in Details.
As an alternative, could I base the value of a checkbox on each line on a query based on the 'Ordernr' field of the current row and the result of a SELECT COUNT from another table and empty field check?
Do I do this in the query the list is based on, or can I bind the extra checkbox field to a query?
A description of how to do this (combine a COUNT and a WHERE "not empty" to yes/no checkbox value) would be perfectly acceptable, I think! :)*
You cannot do much with an unbound control in a continuous form, anything you do will only apply to the current record. You can use a bound control with a click event so that it acts like a button.
Presumably the related documents have a reference to the order number that appears on your form, which means that you can create a control, let us call it CountOrders, with a ControlSource like so:
=DCount("OrderID","QueryName","OrderID=" & [OrderID])
The control can be hidden, or you can set it up to return true or False for use with a textbox, you can also use it for Conditional Formatting, but sadly, not for command buttons.
Expression Is [CountOrders]>0
You can also hide the contents and add a click event so that is acts in place of the command button. Conditional Formatting will allow you to enable or disable a textbox.
As I understand your question, you have a continuous form with as command button that appears on each row - and you'd like to enable/disable the button conditionally depending on the contents of the row.
Unfortunately you can't do that. It seems that you can't reference the individual command buttons separately.
Having wanted to do something similar in the past I came up with two alternate ways of setting up my interface.
Put a trap into the onClick code for the Button. Which is icky, because it is counter intuitive to the user. But it gets you that functionality now.
Move the command button (and editable fields) up into the form header, and make the rows read only. Your users then interact with the record only in the header, and select the record they want work with in the list below. As I recall this is known a Master-Detail interface.