#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Userform

I have a userform that a user inputs data into. I have
set up code that will give a message box if certain
conditions are not satisfied when data is entered into a
text box. When the user click OK on the msgbox, the
textbox is cleared so the proper data can be input.

If Len(txtStk.Value) < 5 Then
MsgBox "Please Check Stock number"
txtStk.Value = ""
txtStk.SetFocus
End If

This all work fine, but the cursor moves to the next box
in the tab order. I would like to cursor to stay in the
txtStk text box. Can anyone see what I am doing wrong
and please help me.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Userform

if you are using the exit event, then setting Cancel = True will cause the
cursor not to move.

--
Regards,
Tom Ogilvy

"Jenny" wrote in message
...
I have a userform that a user inputs data into. I have
set up code that will give a message box if certain
conditions are not satisfied when data is entered into a
text box. When the user click OK on the msgbox, the
textbox is cleared so the proper data can be input.

If Len(txtStk.Value) < 5 Then
MsgBox "Please Check Stock number"
txtStk.Value = ""
txtStk.SetFocus
End If

This all work fine, but the cursor moves to the next box
in the tab order. I would like to cursor to stay in the
txtStk text box. Can anyone see what I am doing wrong
and please help me.

Thank you



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Userform

Hi
in which event do you put this code. Normally this should work?

--
Regards
Frank Kabel
Frankfurt, Germany

"Jenny" schrieb im Newsbeitrag
...
I have a userform that a user inputs data into. I have
set up code that will give a message box if certain
conditions are not satisfied when data is entered into a
text box. When the user click OK on the msgbox, the
textbox is cleared so the proper data can be input.

If Len(txtStk.Value) < 5 Then
MsgBox "Please Check Stock number"
txtStk.Value = ""
txtStk.SetFocus
End If

This all work fine, but the cursor moves to the next box
in the tab order. I would like to cursor to stay in the
txtStk text box. Can anyone see what I am doing wrong
and please help me.

Thank you


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Userform

I am using the "afterupdate" event.

Thanks again


-----Original Message-----
if you are using the exit event, then setting Cancel =

True will cause the
cursor not to move.

--
Regards,
Tom Ogilvy

"Jenny" wrote in

message
...
I have a userform that a user inputs data into. I have
set up code that will give a message box if certain
conditions are not satisfied when data is entered into

a
text box. When the user click OK on the msgbox, the
textbox is cleared so the proper data can be input.

If Len(txtStk.Value) < 5 Then
MsgBox "Please Check Stock number"
txtStk.Value = ""
txtStk.SetFocus
End If

This all work fine, but the cursor moves to the next

box
in the tab order. I would like to cursor to stay in

the
txtStk text box. Can anyone see what I am doing wrong
and please help me.

Thank you



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Userform

If your main purpose is to validate the entry then I would use the exit
event and take advantage of the Cancel argument.

--
Regards,
Tom Ogilvy

"Jenny" wrote in message
...
I am using the "afterupdate" event.

Thanks again


-----Original Message-----
if you are using the exit event, then setting Cancel =

True will cause the
cursor not to move.

--
Regards,
Tom Ogilvy

"Jenny" wrote in

message
...
I have a userform that a user inputs data into. I have
set up code that will give a message box if certain
conditions are not satisfied when data is entered into

a
text box. When the user click OK on the msgbox, the
textbox is cleared so the proper data can be input.

If Len(txtStk.Value) < 5 Then
MsgBox "Please Check Stock number"
txtStk.Value = ""
txtStk.SetFocus
End If

This all work fine, but the cursor moves to the next

box
in the tab order. I would like to cursor to stay in

the
txtStk text box. Can anyone see what I am doing wrong
and please help me.

Thank you



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform Jeff Excel Discussion (Misc queries) 0 February 6th 06 09:30 PM
Access from add_in userform to main template userform.... Ajit Excel Programming 1 November 18th 04 05:15 PM
Linking userform to userform in Excel 2003 missmelis01 Excel Programming 2 August 27th 04 08:07 PM
Little bug in my userform Stift[_34_] Excel Programming 7 July 15th 04 09:46 AM
Userform inside another userform Ryan Excel Programming 0 April 23rd 04 08:01 PM


All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"