Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a form that collects inputs from the user and verifies it against a set of criteria. As it stands at the moment, the code that does the evaluation is triggered by the TextBox Exit event (when the user presses the enter key, tabs or simply clicks elsewhere). This also causes the cursor to move on to the next box in the tab index list. How do I interrupt the tab index list in the event of an error (or point the code back at the textBox in question) so that if the user inputs an invalid value, the cursor remains in that TextBox? TIA Dave |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Use SetFocus, something like this Code: -------------------- Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me If Not IsNumeric(.TextBox1.Value) Then .TextBox1.Value = vbNullString MsgBox "Only numeric entries allowed", vbCritical, "Input error" .TextBox1.SetFocus End If End With End Sub -------------------- -- royUK Hope that helps, RoyUK For tips & examples visit my 'web site' (http://www.excel-it.com/) ------------------------------------------------------------------------ royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=41848 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The Exit event declaration header automatically provides a Cancel
argument... if you don't want to exit the TextBox, just set Cancel=True inside the appropriate section of your code. -- Rick (MVP - Excel) "Risky Dave" wrote in message ... Hi, I have a form that collects inputs from the user and verifies it against a set of criteria. As it stands at the moment, the code that does the evaluation is triggered by the TextBox Exit event (when the user presses the enter key, tabs or simply clicks elsewhere). This also causes the cursor to move on to the next box in the tab index list. How do I interrupt the tab index list in the event of an error (or point the code back at the textBox in question) so that if the user inputs an invalid value, the cursor remains in that TextBox? TIA Dave |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I didn't think of that, much neater Code: -------------------- Option Explicit Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me.TextBox1 If Not IsNumeric(.Value) Then .Value = Empty Cancel = True End If End With End Sub -------------------- -- royUK Hope that helps, RoyUK For tips & examples visit my 'web site' (http://www.excel-it.com/) ------------------------------------------------------------------------ royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=41848 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
clear user form after entry | Excel Programming | |||
user entry form for excel search | Excel Programming | |||
Auto email - With every new entry on my user form | Excel Discussion (Misc queries) | |||
Data Entry Alert in User Form | Excel Discussion (Misc queries) | |||
USer Form Entry to multiple cells | Excel Programming |