After input in text box how do cause AfterUpdate event to run?












0














Still hoping for a solution to this, and hoping the answer is not "You are trying to do too much with Excel!" which I probably am with 14000 LOC so far.



I have an Excel VBA userform with several text boxes.
The user will input a weight in a text box. They can then do other things on the form or click Apply, Update,Previous Event, Next Event or Cancel.



After the weight is input, it must be validated, and then after it is OK, the form is marked as mbFormChanged=True. This validation occurs in the text box's AfterUpdate event.



My problem is that if the user types in a value and immediately clicks Apply, Update, Previous Event or Next Event, the field is not validated and it is if it was never changed.



I.e enter weight: 200[Update]



However, if the user tabs to another field after typing the weight, then it is validated and the form is marked as changed.



I.e. enter weight: 200[Tab][Update]



How can I make sure text AfterEvent runs when a command button is clicked immediately thereafter?



I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid, it immediately updates many other fields and lists visible on the form (real time update.)



Thanks










share|improve this question
























  • Add a Change_Event which will prompt the user (using MsgBox) if he's done entering the weight. If He press ok, then pass the focus using SetFocus property to other controls.
    – L42
    Jul 3 '14 at 8:18
















0














Still hoping for a solution to this, and hoping the answer is not "You are trying to do too much with Excel!" which I probably am with 14000 LOC so far.



I have an Excel VBA userform with several text boxes.
The user will input a weight in a text box. They can then do other things on the form or click Apply, Update,Previous Event, Next Event or Cancel.



After the weight is input, it must be validated, and then after it is OK, the form is marked as mbFormChanged=True. This validation occurs in the text box's AfterUpdate event.



My problem is that if the user types in a value and immediately clicks Apply, Update, Previous Event or Next Event, the field is not validated and it is if it was never changed.



I.e enter weight: 200[Update]



However, if the user tabs to another field after typing the weight, then it is validated and the form is marked as changed.



I.e. enter weight: 200[Tab][Update]



How can I make sure text AfterEvent runs when a command button is clicked immediately thereafter?



I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid, it immediately updates many other fields and lists visible on the form (real time update.)



Thanks










share|improve this question
























  • Add a Change_Event which will prompt the user (using MsgBox) if he's done entering the weight. If He press ok, then pass the focus using SetFocus property to other controls.
    – L42
    Jul 3 '14 at 8:18














0












0








0







Still hoping for a solution to this, and hoping the answer is not "You are trying to do too much with Excel!" which I probably am with 14000 LOC so far.



I have an Excel VBA userform with several text boxes.
The user will input a weight in a text box. They can then do other things on the form or click Apply, Update,Previous Event, Next Event or Cancel.



After the weight is input, it must be validated, and then after it is OK, the form is marked as mbFormChanged=True. This validation occurs in the text box's AfterUpdate event.



My problem is that if the user types in a value and immediately clicks Apply, Update, Previous Event or Next Event, the field is not validated and it is if it was never changed.



I.e enter weight: 200[Update]



However, if the user tabs to another field after typing the weight, then it is validated and the form is marked as changed.



I.e. enter weight: 200[Tab][Update]



How can I make sure text AfterEvent runs when a command button is clicked immediately thereafter?



I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid, it immediately updates many other fields and lists visible on the form (real time update.)



Thanks










share|improve this question















Still hoping for a solution to this, and hoping the answer is not "You are trying to do too much with Excel!" which I probably am with 14000 LOC so far.



I have an Excel VBA userform with several text boxes.
The user will input a weight in a text box. They can then do other things on the form or click Apply, Update,Previous Event, Next Event or Cancel.



After the weight is input, it must be validated, and then after it is OK, the form is marked as mbFormChanged=True. This validation occurs in the text box's AfterUpdate event.



My problem is that if the user types in a value and immediately clicks Apply, Update, Previous Event or Next Event, the field is not validated and it is if it was never changed.



I.e enter weight: 200[Update]



However, if the user tabs to another field after typing the weight, then it is validated and the form is marked as changed.



I.e. enter weight: 200[Tab][Update]



How can I make sure text AfterEvent runs when a command button is clicked immediately thereafter?



I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid, it immediately updates many other fields and lists visible on the form (real time update.)



Thanks







vba excel-vba textbox excel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 9 at 19:34









Community

11




11










asked Jul 3 '14 at 4:20









Shari W

28731024




28731024












  • Add a Change_Event which will prompt the user (using MsgBox) if he's done entering the weight. If He press ok, then pass the focus using SetFocus property to other controls.
    – L42
    Jul 3 '14 at 8:18


















  • Add a Change_Event which will prompt the user (using MsgBox) if he's done entering the weight. If He press ok, then pass the focus using SetFocus property to other controls.
    – L42
    Jul 3 '14 at 8:18
















Add a Change_Event which will prompt the user (using MsgBox) if he's done entering the weight. If He press ok, then pass the focus using SetFocus property to other controls.
– L42
Jul 3 '14 at 8:18




Add a Change_Event which will prompt the user (using MsgBox) if he's done entering the weight. If He press ok, then pass the focus using SetFocus property to other controls.
– L42
Jul 3 '14 at 8:18












2 Answers
2






active

oldest

votes


















0














I assume this is an Excel user form in which case I don't think there is a built in AfterUpdate event. Excel forms are not bound to anything (unlike Access) so there is nothing the form updates. You'll need to make your own AfterUpdate event.






share|improve this answer





















  • Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
    – Shari W
    Jul 3 '14 at 6:28












  • Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
    – Brad
    Jul 3 '14 at 13:08










  • Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
    – Shari W
    Jul 3 '14 at 19:05










  • @ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
    – Brad
    Jul 3 '14 at 19:53






  • 1




    Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
    – Brad
    Jul 3 '14 at 19:54



















-1














As commented, you can try this:



Private Sub TextBox1_Change()
If (MsgBox("Done?", vbYesNo)) = vbYes Then Me.TextBox2.SetFocus 'Or any other ctrl
End Sub


Above code like forces TextBox1_AfterUpdate() event.






share|improve this answer





















  • Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
    – Shari W
    Jul 3 '14 at 19:03











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24544875%2fafter-input-in-text-box-how-do-cause-afterupdate-event-to-run%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I assume this is an Excel user form in which case I don't think there is a built in AfterUpdate event. Excel forms are not bound to anything (unlike Access) so there is nothing the form updates. You'll need to make your own AfterUpdate event.






share|improve this answer





















  • Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
    – Shari W
    Jul 3 '14 at 6:28












  • Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
    – Brad
    Jul 3 '14 at 13:08










  • Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
    – Shari W
    Jul 3 '14 at 19:05










  • @ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
    – Brad
    Jul 3 '14 at 19:53






  • 1




    Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
    – Brad
    Jul 3 '14 at 19:54
















0














I assume this is an Excel user form in which case I don't think there is a built in AfterUpdate event. Excel forms are not bound to anything (unlike Access) so there is nothing the form updates. You'll need to make your own AfterUpdate event.






share|improve this answer





















  • Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
    – Shari W
    Jul 3 '14 at 6:28












  • Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
    – Brad
    Jul 3 '14 at 13:08










  • Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
    – Shari W
    Jul 3 '14 at 19:05










  • @ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
    – Brad
    Jul 3 '14 at 19:53






  • 1




    Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
    – Brad
    Jul 3 '14 at 19:54














0












0








0






I assume this is an Excel user form in which case I don't think there is a built in AfterUpdate event. Excel forms are not bound to anything (unlike Access) so there is nothing the form updates. You'll need to make your own AfterUpdate event.






share|improve this answer












I assume this is an Excel user form in which case I don't think there is a built in AfterUpdate event. Excel forms are not bound to anything (unlike Access) so there is nothing the form updates. You'll need to make your own AfterUpdate event.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 3 '14 at 4:53









Brad

9,62932966




9,62932966












  • Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
    – Shari W
    Jul 3 '14 at 6:28












  • Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
    – Brad
    Jul 3 '14 at 13:08










  • Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
    – Shari W
    Jul 3 '14 at 19:05










  • @ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
    – Brad
    Jul 3 '14 at 19:53






  • 1




    Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
    – Brad
    Jul 3 '14 at 19:54


















  • Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
    – Shari W
    Jul 3 '14 at 6:28












  • Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
    – Brad
    Jul 3 '14 at 13:08










  • Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
    – Shari W
    Jul 3 '14 at 19:05










  • @ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
    – Brad
    Jul 3 '14 at 19:53






  • 1




    Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
    – Brad
    Jul 3 '14 at 19:54
















Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
– Shari W
Jul 3 '14 at 6:28






Yes, Excel. There is a built in AfterUpdate event for all text boxes. Mine is called txtNewWeight_AfterUpdate() in which I have placed my validation script. I just don't know how to make it kick off when the user presses a command button right after typing in a new value.
– Shari W
Jul 3 '14 at 6:28














Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
– Brad
Jul 3 '14 at 13:08




Your after update fires when you leave the textbox. by the time a user has clicked a button the after update has come and gone. Can you not just call the validation code from your button click since that's when you want it to happen?
– Brad
Jul 3 '14 at 13:08












Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
– Shari W
Jul 3 '14 at 19:05




Thanks, but I need to validation to be immediate because in addition to validation, may other related fields are immediately updated before the final OK/Apply is clicked. (Updated my question to say this.)
– Shari W
Jul 3 '14 at 19:05












@ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
– Brad
Jul 3 '14 at 19:53




@ShariW well if the user clicks OK and validation fails you should not be proceeding with your update. You can either validate the textbox when it loses focus (normal AfterUpdate event) or validate the form on your submit button click.
– Brad
Jul 3 '14 at 19:53




1




1




Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
– Brad
Jul 3 '14 at 19:54




Let's think about what you're saying here I can't put the validation at the point of OK/Apply because the moment a user enters a new weight and it is valid [do stuff] you say this is the place to do it right here: and it is valid i.e. passes validation. Click -> validate -> if valid Update your stuff, if not valid call out what is invalid and do no update.
– Brad
Jul 3 '14 at 19:54













-1














As commented, you can try this:



Private Sub TextBox1_Change()
If (MsgBox("Done?", vbYesNo)) = vbYes Then Me.TextBox2.SetFocus 'Or any other ctrl
End Sub


Above code like forces TextBox1_AfterUpdate() event.






share|improve this answer





















  • Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
    – Shari W
    Jul 3 '14 at 19:03
















-1














As commented, you can try this:



Private Sub TextBox1_Change()
If (MsgBox("Done?", vbYesNo)) = vbYes Then Me.TextBox2.SetFocus 'Or any other ctrl
End Sub


Above code like forces TextBox1_AfterUpdate() event.






share|improve this answer





















  • Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
    – Shari W
    Jul 3 '14 at 19:03














-1












-1








-1






As commented, you can try this:



Private Sub TextBox1_Change()
If (MsgBox("Done?", vbYesNo)) = vbYes Then Me.TextBox2.SetFocus 'Or any other ctrl
End Sub


Above code like forces TextBox1_AfterUpdate() event.






share|improve this answer












As commented, you can try this:



Private Sub TextBox1_Change()
If (MsgBox("Done?", vbYesNo)) = vbYes Then Me.TextBox2.SetFocus 'Or any other ctrl
End Sub


Above code like forces TextBox1_AfterUpdate() event.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 3 '14 at 8:19









L42

16.4k73154




16.4k73154












  • Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
    – Shari W
    Jul 3 '14 at 19:03


















  • Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
    – Shari W
    Jul 3 '14 at 19:03
















Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
– Shari W
Jul 3 '14 at 19:03




Thanks. This would work for some apps and input types, but not for mine. It checks for done after every character input. So if I have to type in 75.3, the question would come up four times. Even one time is too much. I need it to detect when the cursor leaves that box (?)
– Shari W
Jul 3 '14 at 19:03


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24544875%2fafter-input-in-text-box-how-do-cause-afterupdate-event-to-run%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ