Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Goto Specific Textbox in Userform

I am developing userform that needs to validate any change in a textbox.
If the new data is outside of the specified region, then I want the current
textbox to be remain selected, but unfortunately I cant find a way to do this.

The code I am currently using is

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value = Format(Me.BENCH_Tour_Amber_txt.Value, "")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation

End If
End Sub

Also
This re-occurs numerous times in the same userform, so is it possible to
write the code no matter which textbox is "exited", or will I just have to
repeat for each textbox??

Thanks for any help that you can give.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Goto Specific Textbox in Userform

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value = Format(Me.BENCH_Tour_Amber_txt.Value,
"")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation
Cancel = True
End If
End Sub

For the exit event, since it is provided by the controls container, you
would need to create one for each textbox.

--
Regards,
Tom Ogilvy


"Kris_Wright_77" wrote in message
...
I am developing userform that needs to validate any change in a textbox.
If the new data is outside of the specified region, then I want the

current
textbox to be remain selected, but unfortunately I cant find a way to do

this.

The code I am currently using is

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value = Format(Me.BENCH_Tour_Amber_txt.Value,

"")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation

End If
End Sub

Also
This re-occurs numerous times in the same userform, so is it possible to
write the code no matter which textbox is "exited", or will I just have to
repeat for each textbox??

Thanks for any help that you can give.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Goto Specific Textbox in Userform

Thanks
Works exactly the way I wanted.

Could you let me know why this works?
I have seen it used similarly in other pieces of code that I have found and
adapted from this forum, and obviously didn't need to understand
My VBA is entirely self taught, and haven't been able to find any
explanations in the couple of reference books that I have.

Kris

"Tom Ogilvy" wrote:

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value = Format(Me.BENCH_Tour_Amber_txt.Value,
"")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation
Cancel = True
End If
End Sub

For the exit event, since it is provided by the controls container, you
would need to create one for each textbox.

--
Regards,
Tom Ogilvy


"Kris_Wright_77" wrote in message
...
I am developing userform that needs to validate any change in a textbox.
If the new data is outside of the specified region, then I want the

current
textbox to be remain selected, but unfortunately I cant find a way to do

this.

The code I am currently using is

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value = Format(Me.BENCH_Tour_Amber_txt.Value,

"")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation

End If
End Sub

Also
This re-occurs numerous times in the same userform, so is it possible to
write the code no matter which textbox is "exited", or will I just have to
repeat for each textbox??

Thanks for any help that you can give.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Goto Specific Textbox in Userform

Cancel is a variable defined by the event declaration. If is found in the
argument list of most events that start with BEFORE and it used to signal
the triggering activity not to occur. While exit is not entitled
BeforeExit, setting cancel to true still causes the Exit action not to
occur.

--
Regards,
Tom Ogilvy


"Kris_Wright_77" wrote in message
...
Thanks
Works exactly the way I wanted.

Could you let me know why this works?
I have seen it used similarly in other pieces of code that I have found

and
adapted from this forum, and obviously didn't need to understand
My VBA is entirely self taught, and haven't been able to find any
explanations in the couple of reference books that I have.

Kris

"Tom Ogilvy" wrote:

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value =

Format(Me.BENCH_Tour_Amber_txt.Value,
"")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation
Cancel = True
End If
End Sub

For the exit event, since it is provided by the controls container, you
would need to create one for each textbox.

--
Regards,
Tom Ogilvy


"Kris_Wright_77" wrote in

message
...
I am developing userform that needs to validate any change in a

textbox.
If the new data is outside of the specified region, then I want the

current
textbox to be remain selected, but unfortunately I cant find a way to

do
this.

The code I am currently using is

Private Sub BENCH_Tour_Amber_txt_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If Not BENCH_Tour_Amber_txt.Value < 100 Then
BENCH_Tour_Amber_txt.Value =

Format(Me.BENCH_Tour_Amber_txt.Value,
"")
Else
MsgBox Prompt:="Amber Tolerance Must Be Between 0 & 100",
Buttons:=vbExclamation

End If
End Sub

Also
This re-occurs numerous times in the same userform, so is it possible

to
write the code no matter which textbox is "exited", or will I just

have to
repeat for each textbox??

Thanks for any help that you can give.






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
Macro to goto specific cell (todays date) crimekilla Excel Discussion (Misc queries) 4 May 11th 10 04:42 PM
Goto a specific cell in a macro Edward Excel Discussion (Misc queries) 0 July 16th 07 08:24 PM
Locate/goto a specific worksheet quickly johanc Excel Worksheet Functions 4 July 7th 06 04:18 PM
Textbox in userform Harald Staff Excel Programming 0 September 8th 04 11:51 AM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 10:24 AM.

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

About Us

"It's about Microsoft Excel"