How do I update the value in one text box (txtInterest%
) based on the value entered/changed in another text box (txtAmt
)?
Highlight the textbox called Textbox1. Click on the property called "After Update". A button with 3 dots to the right should appear. Click on this button. When the Choose Builder window appears, highlight Code Builder. Click on the OK button. Now, when a value of 1 is entered in Textbox1, Textbox2 will automatically be populated with a value of 10.
For example, if someone enters a value of 1 in Textbox1, then I want to set Textbox2 = 10. Answer: To set the value of Textbox2 based on the value entered in Textbox1, you need to place your VBA code on the "After Update" event of Textbox1. To do this, open your form in Design View. Under the View menu, select Properties.
The defaut value can be anything you like in your third textbox, but, for you example to work you need to set the Text proprety of the third textbox to TxtReveived.Text. For your last TxtRecieved.Text value should be reflected as a.
When the Choose Builder window appears, highlight Code Builder. Click on the OK button. Now, when a value of 1 is entered in Textbox1, Textbox2 will automatically be populated with a value of 10.
Use jQuery's change method for updating. Using your example:
$('#txtAmt').change(function() {
//get txtAmt value
var txtAmtval = $('#txtAmt').val();
//change txtInterest% value
$('#txtInterest%').val(txtAmtval);
});
This should work assuming txtAmt
and txtInterest%
are id
s on your page:
$(function() {
$('#txtAmt').change(function() {
$('#txtInterest%').val(this.value);
});
});
See jQuery's change
event handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With