ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error on textbox entry - Go back to text box (https://www.excelbanter.com/excel-programming/414079-error-textbox-entry-go-back-text-box.html)

Les

Error on textbox entry - Go back to text box
 
Hi all,

I have code that check if the entry in a text box is correct..... this code
is using/in the beforeUpdate Event.

It works great, with the exception of the cursor jumping to the next
textbox, if it is an error i would like the cursor to go back to the textbox
with the error for re-entry.

I am batteling to get this !!!
Any help would be apprciated.

--
Les

Charlie

Error on textbox entry - Go back to text box
 
If your code is in the sheet module then

TextBox1.Activate

if your code is in a standard module then

Sheet1.TextBox1.Activate


"Les" wrote:

Hi all,

I have code that check if the entry in a text box is correct..... this code
is using/in the beforeUpdate Event.

It works great, with the exception of the cursor jumping to the next
textbox, if it is an error i would like the cursor to go back to the textbox
with the error for re-entry.

I am batteling to get this !!!
Any help would be apprciated.

--
Les


RyanH

Error on textbox entry - Go back to text box
 
I would use this.

Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)

If TextBox1.Text < "test" Then
Cancel = True

' *******your code here*****

End If

End Sub

Hope this helps. If so please click "yes" below.
--
Cheers,
Ryan


"Les" wrote:

Hi all,

I have code that check if the entry in a text box is correct..... this code
is using/in the beforeUpdate Event.

It works great, with the exception of the cursor jumping to the next
textbox, if it is an error i would like the cursor to go back to the textbox
with the error for re-entry.

I am batteling to get this !!!
Any help would be apprciated.

--
Les



All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com