![]() |
|
![]() | ||
|
Subject:
VBA/Excel SetFocus Problem
Category: Computers > Programming Asked by: jpbischke-ga List Price: $2.50 |
Posted:
05 Nov 2002 13:32 PST
Expires: 07 Nov 2002 14:37 PST Question ID: 99681 |
I'm running into a problem getting the focus to change on a VBA UserForm in Excel 2002. This seems like it should be so easy but for whatever reason I can't get it to take. What I want to do is validate data that a user enters into a text box. If the data is within acceptable parameters then the focus moves to the next text box. If the data is not within acceptable parameters then a message box pops up telling the user how to correct the error. At this point in time I would like the focus to return to the text box (rather than going to the next text box), essentially trapping the user there until valid data is entered. I'm using the BeforeUpdate event for the text box with the following code that is executed if the input is not within the parameters: txtInputBox.SetFocus where txtInputBox is the name of the text box. I've also tried using me.txtInputBox.SetFocus but that doesn't seem to work either. The code is being run as I have substituted test code in its place and it runs fine. Regardless of what I seem to do, the focus always ends up on the next text field. Any ideas? | |
| |
| |
|
![]() | ||
|
There is no answer at this time. |
![]() | ||
|
Subject:
Re: VBA/Excel SetFocus Problem
From: kproth-ga on 05 Nov 2002 15:39 PST |
Have you tried canceling the BeforeUpdate event in your code? Usually this event has an input parameter named Cancel, which, when set to True, will cancel the rest of the events (AfterUpdate, Exit, LostFocus, etc). |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |