Clear a form field and then set it to read only - formatting

I have a check box and a text field in my InfoPath form. When the check box is unchecked, I would like to clear the field content and then mark it as read-only.
I created a conditional formatting to mark the form as read-only and then a rule to clear the field content. However, I found that every time I enable both of them, the rule will not run.
To make sure, I created a pop-up dialog box in the rule too and I found every time I enable the conditional formatting to change the text field as read-only the dialog box will not show.
I am suspecting that by changing the text field to read-only suppresses the rule, which clears the text field content. Anyone knows how to fix this?

Yeah this is weird...
If you go back and add a rule to the checkbox to update the value of the textbox when the checkbox value is "True". You will see that the rule on the textbox is now picked up.
I'm not sure why this is the case but I assume that its because the conditional formating stops all rules on the control and by adding a new rule to the checkbox it kick starts the rules on the control.

This is surely a bug with InfoPath, since i've had the same difficulty combining conditional formatting with rules (the conditional change never changes the formatting)

Put the rule onto the control whose value you are changing, so in this case, add the rule to the checkbox, not the field you wish to clear.
You can also add the conditional formatting to the textbox at the same time as this should not affect the outcome of the rule.

Related

Opposite of SetFocus

MSAccess VBA:
Assume, in an arbitrary form, the focus is set to MyControl on that form.
How to "unset" the focus without giving the focus to another control?
I'm lokking for a code like
MyControl.UnsetFocus
In your circumstance, you probably want to just set focus back to the parent form. This meets the conditions of unsetting focus without giving another control focus, and tabbing or clicking will activate the focus / tab-navigation again from that form.
Here's an example:
Forms![MyForm].SetFocus
Note that per the documentation for SetFocus, if you attempt to SetFocus to a Form with child controls that have Enabled set, this will cause focus to automatically bounce to the first eligible child control per the documentation.
Form.SetFocus method (Access) # Microsoft Docs
The option to give focus to the parent form does work as proposed by meklarian
Alternatively, I recently had to do something similar but I wanted to update a textbox value and simply go back to whatever had focus before. This is another case where something like an "unsetfocus" would be awesome, but unfortunately doesn't exist.
Should you need to do something like this, the following works well
Screen.PreviousControl.SetFocus

VB.NET ComboBox Not Recognising Text Change

I have an application whereby I have the behaviour of 2 groupboxes enable/disable based on the value in a combobox.
This combobox however the behaviour for the group boxes only works when I leave the field by tab or click, not when the text changes.
I have tried using the Leave, TextChanged, Validated Events and everytime I have to actually "Leave" the field for it to perform the enabled/disabled of the groupboxes and their subsequent controls.
I need it so that when they choose 1 of the 3 options it immediately changes and doesn't work when they leave the field but when they choose the correct word.
Any assistance would be great I'm tearing my hair out here.
I think you are looking for the event on your combo boxes
SelectedIndexChanged
To stop the user from leaving an invalid field use the event
Validating
set the e.cancel to True if the validation fails

Submitting an Infopath form section by section while making previous section uneditable

I have a InfoPath 2013 form in three sections. When one section is submitted I need the previous one to be become read-only/un-editable. I thought the approach might be to use Views as detailed here but I need to be able to submit the sections to a list as well as toggle.
I also though that Conditional Formatting might be the approach but when I righ click on the sectors I don't get the option. Any ideas?
Sections options
You can make section's elements disable.
For example, create checkbox chkOne. If Section2 was submitted, change chkOne's value to true. And add Formatting rule for all Section1's controls "If chkOne is true - disable".

Windows form freezes when bound combobox selection is made

I have a pretty simple form that brings up a certain record when the "caseNumber" is selected from the combobox. Although after a selection is made within the combobox, it will freeze the entire form on the record selected. I can't click on any other text boxes or buttons. I have to stop the debugger. No errors are thrown. I've read where this has happened to others, but no answers to the problem, that I can find.
There is no code behind it so far, as the form is bound to a dataset and should just bring up the rest of the information once the caseNumber is selected.
Changed the "Selected Value" dropbox to "none" on the data binding menu for the combobox.
Under DataBindings, go to Advanced and make sure DataSource update mode is on NOne
A lot of times this happens because there is a problem in the binding. Are you sure it's not binding the text value of the control(the combobobox) to the data?
The correct way to bind (under DataBindings, Advanced) was to bind it to the SelectedValue instead of Text.
Please let us know a little bit more how your combobox is binded.

How to use Mouseout Function in VBA with a condition Check?

Hi I have a VBA application with a combobox selection option.One of the combobox option is Other which when user select that option an invisibled label will pops up and prompt the user to fill the txtOther control.now my question is how I can get rid of the prompted label and make it to invisible after user fill the txtOther and move(focused)in other control?
here is a shot of my app:
Thanks for your time and help
It depends on how often or when you want the check to be done. I couldn't find a good reference to show you all of this, but you can view your VBE.
Within the code behind your userform you can use events for the text box.
If you want the check done every time you leave the text box:
Use the TextBox_Exit event.
If you want it to fire whenever the contents are changed, used TextBox_Change. There's lots of options, but based on your explanation I'd probably use Exit.
This answer shows some syntax examples for using the Textbox_Exit event.