Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Validation subroutine for textboxes

I hav a Userform with 24 textboxes on it. I would like to call a generic
validation routine on each change event. My problem is how do I generically
reference the control's value in the Change event routine ?

Here's what I am trying to do:

Private Sub txtOverallForward_Change()
CheckRange (Me.txtOverallForward.Value)
End Sub

but is there a way to do something like:
Private Sub txtOverallForward_Change()
CheckRange (Me.ActiveControl.Value) <-------
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Validation subroutine for textboxes

Pass the textbox itself.

Private Sub txtOverallForward_Change()
CheckRange Me.txtOverallForward
End Sub

Sub CheckRange(TBox as msforms.textbox)
msgbox TBox.value
end sub



chemicals wrote:

I hav a Userform with 24 textboxes on it. I would like to call a generic
validation routine on each change event. My problem is how do I generically
reference the control's value in the Change event routine ?

Here's what I am trying to do:

Private Sub txtOverallForward_Change()
CheckRange (Me.txtOverallForward.Value)
End Sub

but is there a way to do something like:
Private Sub txtOverallForward_Change()
CheckRange (Me.ActiveControl.Value) <-------
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validation subroutine for textboxes

Or, since the OP appears to be calling the subroutine from within event
procedures for the actual controls themselves, don't pass any argument and
use the ActiveControl object to reference the control...

Private Sub txtOverallForward_Change()
CheckRange
End Sub

Sub CheckRange()
MsgBox ActiveControl.Value
End Sub

Rick


"Dave Peterson" wrote in message
...
Pass the textbox itself.

Private Sub txtOverallForward_Change()
CheckRange Me.txtOverallForward
End Sub

Sub CheckRange(TBox as msforms.textbox)
msgbox TBox.value
end sub



chemicals wrote:

I hav a Userform with 24 textboxes on it. I would like to call a generic
validation routine on each change event. My problem is how do I
generically
reference the control's value in the Change event routine ?

Here's what I am trying to do:

Private Sub txtOverallForward_Change()
CheckRange (Me.txtOverallForward.Value)
End Sub

but is there a way to do something like:
Private Sub txtOverallForward_Change()
CheckRange (Me.ActiveControl.Value) <-------
End Sub


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Validation subroutine for textboxes

THANKS RICK. That's what I wanted as I am lazy and didn't want to have to
type the textbox name in for every validation call....!



"Rick Rothstein (MVP - VB)" wrote:

Or, since the OP appears to be calling the subroutine from within event
procedures for the actual controls themselves, don't pass any argument and
use the ActiveControl object to reference the control...

Private Sub txtOverallForward_Change()
CheckRange
End Sub

Sub CheckRange()
MsgBox ActiveControl.Value
End Sub

Rick


"Dave Peterson" wrote in message
...
Pass the textbox itself.

Private Sub txtOverallForward_Change()
CheckRange Me.txtOverallForward
End Sub

Sub CheckRange(TBox as msforms.textbox)
msgbox TBox.value
end sub



chemicals wrote:

I hav a Userform with 24 textboxes on it. I would like to call a generic
validation routine on each change event. My problem is how do I
generically
reference the control's value in the Change event routine ?

Here's what I am trying to do:

Private Sub txtOverallForward_Change()
CheckRange (Me.txtOverallForward.Value)
End Sub

but is there a way to do something like:
Private Sub txtOverallForward_Change()
CheckRange (Me.ActiveControl.Value) <-------
End Sub


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Validation subroutine for textboxes

My bad!
ActiveControl.Value returns the value of the page in the Multipage (i.e.
0,1,2,3,4)

I have 5 multipage tabs each containing 24 textboxes so I needed to
reference the "active" textbox this way.....

ActiveControl.SelectedItem.ActiveControl.Value


"Rick Rothstein (MVP - VB)" wrote:

Or, since the OP appears to be calling the subroutine from within event
procedures for the actual controls themselves, don't pass any argument and
use the ActiveControl object to reference the control...

Private Sub txtOverallForward_Change()
CheckRange
End Sub

Sub CheckRange()
MsgBox ActiveControl.Value
End Sub

Rick


"Dave Peterson" wrote in message
...
Pass the textbox itself.

Private Sub txtOverallForward_Change()
CheckRange Me.txtOverallForward
End Sub

Sub CheckRange(TBox as msforms.textbox)
msgbox TBox.value
end sub



chemicals wrote:

I hav a Userform with 24 textboxes on it. I would like to call a generic
validation routine on each change event. My problem is how do I
generically
reference the control's value in the Change event routine ?

Here's what I am trying to do:

Private Sub txtOverallForward_Change()
CheckRange (Me.txtOverallForward.Value)
End Sub

but is there a way to do something like:
Private Sub txtOverallForward_Change()
CheckRange (Me.ActiveControl.Value) <-------
End Sub


--

Dave Peterson



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
Call a subroutine using variable subroutine name dhstein Excel Discussion (Misc queries) 3 July 26th 09 08:28 PM
Show Results in TextBoxes, ONLY if All TextBoxes have Data in them RyanH Excel Programming 3 November 19th 07 03:30 PM
How To Quit Subroutine from a called subroutine Rich J[_2_] Excel Programming 5 February 20th 07 06:48 PM
format validation in UserForm textboxes Soultek Excel Programming 1 February 1st 07 07:37 PM
Every second subroutine dolegow Excel Programming 1 October 12th 03 02:11 AM


All times are GMT +1. The time now is 07:25 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"