Textbox AfterUpdate problem 
Author Message
 Textbox AfterUpdate problem

Hei !

I have a userform with some textboxes. The user enters data into the first
textbox hits TAB and move to the next textbox.
When the user clicks an OK button some calculations are made using the
values in the textboxes.

To evaluate the input in the textboxes I use TextBox_AfterUpdate, but it
doesn't behave as I want it to. I thought that TextBox1.SetFocus would
select Textbox1, but it doesn't. Any ideas anyone ?

Private Sub TextBox1_AfterUpdate()
        On Error Resume Next
        Select Case TextBox1.Value
        Case Is < 440
            MsgBox "Vannstand for lav, LRV=440,00. Pr?v igjen !",
vbExclamation, "Tabbe !"
            UserForm1.TextBox1 = ""
            TextBox1.SetFocus   '****Why doesn't this work ?
            Exit Sub
        Case Is > 454
            MsgBox "Vannstand for H?y, HRV=454,00. Pr?v igjen !",
vbExclamation, "Tabbe !"
            UserForm1.TextBox1 = ""
            TextBox1.SetFocus
            Exit Sub
        End Select
End Sub

Knut Egil



Wed, 18 Jun 1902 08:00:00 GMT  
 Textbox AfterUpdate problem
Hi Knut,

    The TextBox_AfterUpdate event is very unreliable. I would suggest not
using it. It would be better to do as much rule enforcement as you can using
other properties and events such as MaxLength and TextBox_KeyPress, then do
your final validation in the OK button click event.

--
Rob Bovey, MCSE, MCSD
Application Professionals
http://www.appspro.com
* Please post all responses to this newsgroup *
* I delete all unsolicited e-mail messages *



Quote:
> Hei !

> I have a userform with some textboxes. The user enters data into the first
> textbox hits TAB and move to the next textbox.
> When the user clicks an OK button some calculations are made using the
> values in the textboxes.

> To evaluate the input in the textboxes I use TextBox_AfterUpdate, but it
> doesn't behave as I want it to. I thought that TextBox1.SetFocus would
> select Textbox1, but it doesn't. Any ideas anyone ?

> Private Sub TextBox1_AfterUpdate()
>         On Error Resume Next
>         Select Case TextBox1.Value
>         Case Is < 440
>             MsgBox "Vannstand for lav, LRV=440,00. Pr?v igjen !",
> vbExclamation, "Tabbe !"
>             UserForm1.TextBox1 = ""
>             TextBox1.SetFocus   '****Why doesn't this work ?
>             Exit Sub
>         Case Is > 454
>             MsgBox "Vannstand for H?y, HRV=454,00. Pr?v igjen !",
> vbExclamation, "Tabbe !"
>             UserForm1.TextBox1 = ""
>             TextBox1.SetFocus
>             Exit Sub
>         End Select
> End Sub

> Knut Egil



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. AfterUpdate event problem for a textbox on a form

2. textbox AfterUpdate event

3. AfterUpdate on Textbox fires more than once.

4. setfocus of a textbox AfterUpdate

5. TextBox and AfterUpdate Event

6. AfterUpdate For TextBox Not Launching?

7. SetFocus Problem + AfterUpdate Problem

8. userform afterupdate problem.

9. mainform control AfterUpdate problem?

10. AfterUpdate Problem


 
Powered by phpBB® Forum Software © phpBB Group