+ Reply to Thread
Results 1 to 10 of 10

change value on a form

  1. #1
    Liedson31
    Guest

    change value on a form

    hi everyone.

    i have a function that i want to run everytime the user change a value from
    all textboxes included on a form. i don´t want to put code on every
    textbox,i´m asking if is that any way that once the user input a value on one
    textbox i run a function.have the forms a change event or similar that let me
    do this?

    thanks in advance
    Miguel


  2. #2
    Bob Phillips
    Guest

    Re: change value on a form

    Private Sub TextBox1_Change()
    myCommonMacro
    End Sub


    etc., or else youy can modify John Walkenbach's technique shown here
    http://j-walk.com/ss/excel/tips/tip44.htm

    --
    HTH

    Bob Phillips

    "Liedson31" <[email protected]> wrote in message
    news:[email protected]...
    > hi everyone.
    >
    > i have a function that i want to run everytime the user change a value

    from
    > all textboxes included on a form. i don´t want to put code on every
    > textbox,i´m asking if is that any way that once the user input a value on

    one
    > textbox i run a function.have the forms a change event or similar that let

    me
    > do this?
    >
    > thanks in advance
    > Miguel
    >




  3. #3
    Liedson31
    Guest

    Re: change value on a form

    thanks bob....
    the John Walkenbach's technique works perfectly with the command button..but
    if i try to change it,to have a group of textboxes..it gives me a error..

    instead of
    Public WithEvents ButtonGroup As CommandButton
    Public WithEvents TextBoxGroup As TextBox


    "Bob Phillips" wrote:

    > Private Sub TextBox1_Change()
    > myCommonMacro
    > End Sub
    >
    >
    > etc., or else youy can modify John Walkenbach's technique shown here
    > http://j-walk.com/ss/excel/tips/tip44.htm
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Liedson31" <[email protected]> wrote in message
    > news:[email protected]...
    > > hi everyone.
    > >
    > > i have a function that i want to run everytime the user change a value

    > from
    > > all textboxes included on a form. i don´t want to put code on every
    > > textbox,i´m asking if is that any way that once the user input a value on

    > one
    > > textbox i run a function.have the forms a change event or similar that let

    > me
    > > do this?
    > >
    > > thanks in advance
    > > Miguel
    > >

    >
    >
    >


  4. #4
    Liedson31
    Guest

    Re: change value on a form

    thanks Bob

    John Walkenbach's technique works fine and it's what i´m looking for...but
    with textboxes!
    instead of - Public WithEvents ButtonGroup As CommandButton
    i put - Public WithEvents TextBoxGroup As TextBox

    and it gives me an "object does not source automation events"
    can you help me with this once more please.

    thanks in advance
    Miguel



    "Bob Phillips" wrote:

    > Private Sub TextBox1_Change()
    > myCommonMacro
    > End Sub
    >
    >
    > etc., or else youy can modify John Walkenbach's technique shown here
    > http://j-walk.com/ss/excel/tips/tip44.htm
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Liedson31" <[email protected]> wrote in message
    > news:[email protected]...
    > > hi everyone.
    > >
    > > i have a function that i want to run everytime the user change a value

    > from
    > > all textboxes included on a form. i don´t want to put code on every
    > > textbox,i´m asking if is that any way that once the user input a value on

    > one
    > > textbox i run a function.have the forms a change event or similar that let

    > me
    > > do this?
    > >
    > > thanks in advance
    > > Miguel
    > >

    >
    >
    >


  5. #5
    Tom Ogilvy
    Guest

    Re: change value on a form

    Public WithEvents TextBoxGroup As MSForms.TextBox


    --
    Regards,
    Tom Ogilvy


    "Liedson31" <[email protected]> wrote in message
    news:[email protected]...
    > thanks Bob
    >
    > John Walkenbach's technique works fine and it's what i´m looking for...but
    > with textboxes!
    > instead of - Public WithEvents ButtonGroup As CommandButton
    > i put - Public WithEvents TextBoxGroup As TextBox
    >
    > and it gives me an "object does not source automation events"
    > can you help me with this once more please.
    >
    > thanks in advance
    > Miguel
    >
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Private Sub TextBox1_Change()
    > > myCommonMacro
    > > End Sub
    > >
    > >
    > > etc., or else youy can modify John Walkenbach's technique shown here
    > > http://j-walk.com/ss/excel/tips/tip44.htm
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Liedson31" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > hi everyone.
    > > >
    > > > i have a function that i want to run everytime the user change a value

    > > from
    > > > all textboxes included on a form. i don´t want to put code on every
    > > > textbox,i´m asking if is that any way that once the user input a value

    on
    > > one
    > > > textbox i run a function.have the forms a change event or similar that

    let
    > > me
    > > > do this?
    > > >
    > > > thanks in advance
    > > > Miguel
    > > >

    > >
    > >
    > >




  6. #6
    Liedson31
    Guest

    Re: change value on a form

    sorry Bob my previous doubt....i already did the adjustment that John talk
    about
    i forgot the part MsForms.TextBox.
    Now i have all the textboxes grouped...
    the question is....i try instead of command_click the
    private Sub TextBoxGroup_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    --here i have the code
    end sub

    but it never enters here,can you help me?
    thanks
    Miguel



    "Bob Phillips" wrote:

    > Private Sub TextBox1_Change()
    > myCommonMacro
    > End Sub
    >
    >
    > etc., or else youy can modify John Walkenbach's technique shown here
    > http://j-walk.com/ss/excel/tips/tip44.htm
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Liedson31" <[email protected]> wrote in message
    > news:[email protected]...
    > > hi everyone.
    > >
    > > i have a function that i want to run everytime the user change a value

    > from
    > > all textboxes included on a form. i don´t want to put code on every
    > > textbox,i´m asking if is that any way that once the user input a value on

    > one
    > > textbox i run a function.have the forms a change event or similar that let

    > me
    > > do this?
    > >
    > > thanks in advance
    > > Miguel
    > >

    >
    >
    >


  7. #7
    Tom Ogilvy
    Guest

    Re: change value on a form

    Exit isn't an event of the textbox. It is an event of the control (the
    container for the textbox). You can't use John's method with the container
    events.

    Perhaps you can use one of the textbox events to trigger appropriately.

    --
    Regards,
    Tom Ogilvy

    "Liedson31" <[email protected]> wrote in message
    news:[email protected]...
    > sorry Bob my previous doubt....i already did the adjustment that John talk
    > about
    > i forgot the part MsForms.TextBox.
    > Now i have all the textboxes grouped...
    > the question is....i try instead of command_click the
    > private Sub TextBoxGroup_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    > --here i have the code
    > end sub
    >
    > but it never enters here,can you help me?
    > thanks
    > Miguel
    >
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Private Sub TextBox1_Change()
    > > myCommonMacro
    > > End Sub
    > >
    > >
    > > etc., or else youy can modify John Walkenbach's technique shown here
    > > http://j-walk.com/ss/excel/tips/tip44.htm
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Liedson31" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > hi everyone.
    > > >
    > > > i have a function that i want to run everytime the user change a value

    > > from
    > > > all textboxes included on a form. i don´t want to put code on every
    > > > textbox,i´m asking if is that any way that once the user input a value

    on
    > > one
    > > > textbox i run a function.have the forms a change event or similar that

    let
    > > me
    > > > do this?
    > > >
    > > > thanks in advance
    > > > Miguel
    > > >

    > >
    > >
    > >




  8. #8
    Bob Phillips
    Guest

    Re: change value on a form

    This method does not support the Exit event for textboxes. You need to go
    into the calls module and see what events are supported.

    This is the code that I used

    >>>>>>>>>>>>>> Class Module


    Public WithEvents TextBoxGroup As MSForms.TextBox

    Private Sub TextBoxGroup_Change()
    MsgBox "hello"
    End Sub

    >>>>>>>>>>>>>> Standard Module


    Dim TextBoxes() As New Class1

    Sub ShowDialog()
    Dim TextBoxCount As Integer
    Dim ctl As Control

    ' Create the Button objects
    TextBoxCount = 0
    For Each ctl In UserForm1.Controls
    If TypeName(ctl) = "TextBox" Then
    TextBoxCount = TextBoxCount + 1
    ReDim Preserve TextBoxes(1 To TextBoxCount)
    Set TextBoxes(TextBoxCount).TextBoxGroup = ctl
    End If
    Next ctl
    UserForm1.Show
    End Sub

    --
    HTH

    Bob Phillips

    "Liedson31" <[email protected]> wrote in message
    news:[email protected]...
    > sorry Bob my previous doubt....i already did the adjustment that John talk
    > about
    > i forgot the part MsForms.TextBox.
    > Now i have all the textboxes grouped...
    > the question is....i try instead of command_click the
    > private Sub TextBoxGroup_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    > --here i have the code
    > end sub
    >
    > but it never enters here,can you help me?
    > thanks
    > Miguel
    >
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Private Sub TextBox1_Change()
    > > myCommonMacro
    > > End Sub
    > >
    > >
    > > etc., or else youy can modify John Walkenbach's technique shown here
    > > http://j-walk.com/ss/excel/tips/tip44.htm
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Liedson31" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > hi everyone.
    > > >
    > > > i have a function that i want to run everytime the user change a value

    > > from
    > > > all textboxes included on a form. i don´t want to put code on every
    > > > textbox,i´m asking if is that any way that once the user input a value

    on
    > > one
    > > > textbox i run a function.have the forms a change event or similar that

    let
    > > me
    > > > do this?
    > > >
    > > > thanks in advance
    > > > Miguel
    > > >

    > >
    > >
    > >




  9. #9
    Liedson31
    Guest

    Re: change value on a form

    THANKS VERY MUCH BOTH ,Bob and Tom
    That works perfectly...i don´t notice the support methods,with the change or
    the keypress method, solves my problem.

    Miguel

    "Bob Phillips" wrote:

    > This method does not support the Exit event for textboxes. You need to go
    > into the calls module and see what events are supported.
    >
    > This is the code that I used
    >
    > >>>>>>>>>>>>>> Class Module

    >
    > Public WithEvents TextBoxGroup As MSForms.TextBox
    >
    > Private Sub TextBoxGroup_Change()
    > MsgBox "hello"
    > End Sub
    >
    > >>>>>>>>>>>>>> Standard Module

    >
    > Dim TextBoxes() As New Class1
    >
    > Sub ShowDialog()
    > Dim TextBoxCount As Integer
    > Dim ctl As Control
    >
    > ' Create the Button objects
    > TextBoxCount = 0
    > For Each ctl In UserForm1.Controls
    > If TypeName(ctl) = "TextBox" Then
    > TextBoxCount = TextBoxCount + 1
    > ReDim Preserve TextBoxes(1 To TextBoxCount)
    > Set TextBoxes(TextBoxCount).TextBoxGroup = ctl
    > End If
    > Next ctl
    > UserForm1.Show
    > End Sub
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Liedson31" <[email protected]> wrote in message
    > news:[email protected]...
    > > sorry Bob my previous doubt....i already did the adjustment that John talk
    > > about
    > > i forgot the part MsForms.TextBox.
    > > Now i have all the textboxes grouped...
    > > the question is....i try instead of command_click the
    > > private Sub TextBoxGroup_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    > > --here i have the code
    > > end sub
    > >
    > > but it never enters here,can you help me?
    > > thanks
    > > Miguel
    > >
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Private Sub TextBox1_Change()
    > > > myCommonMacro
    > > > End Sub
    > > >
    > > >
    > > > etc., or else youy can modify John Walkenbach's technique shown here
    > > > http://j-walk.com/ss/excel/tips/tip44.htm
    > > >
    > > > --
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > "Liedson31" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > hi everyone.
    > > > >
    > > > > i have a function that i want to run everytime the user change a value
    > > > from
    > > > > all textboxes included on a form. i don´t want to put code on every
    > > > > textbox,i´m asking if is that any way that once the user input a value

    > on
    > > > one
    > > > > textbox i run a function.have the forms a change event or similar that

    > let
    > > > me
    > > > > do this?
    > > > >
    > > > > thanks in advance
    > > > > Miguel
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  10. #10
    Excelerate-nl
    Guest

    Re: change value on a form

    Dear Bob and others,

    This was a very usefull tip.

    I would like to add a possibly usefull comment:
    You can modify the:
    For Each ctl In UserForm1.Controls
    to
    For Each ctl In UserForm1.Frame1.Controls
    to make a selection of Controls on a Userform, i.e. those that are within
    Frame1.

    Regards,
    Jan Bart


    "Bob Phillips" wrote:

    > This method does not support the Exit event for textboxes. You need to go
    > into the calls module and see what events are supported.
    >
    > This is the code that I used
    >
    > >>>>>>>>>>>>>> Class Module

    >
    > Public WithEvents TextBoxGroup As MSForms.TextBox
    >
    > Private Sub TextBoxGroup_Change()
    > MsgBox "hello"
    > End Sub
    >
    > >>>>>>>>>>>>>> Standard Module

    >
    > Dim TextBoxes() As New Class1
    >
    > Sub ShowDialog()
    > Dim TextBoxCount As Integer
    > Dim ctl As Control
    >
    > ' Create the Button objects
    > TextBoxCount = 0
    > For Each ctl In UserForm1.Controls
    > If TypeName(ctl) = "TextBox" Then
    > TextBoxCount = TextBoxCount + 1
    > ReDim Preserve TextBoxes(1 To TextBoxCount)
    > Set TextBoxes(TextBoxCount).TextBoxGroup = ctl
    > End If
    > Next ctl
    > UserForm1.Show
    > End Sub
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Liedson31" <[email protected]> wrote in message
    > news:[email protected]...
    > > sorry Bob my previous doubt....i already did the adjustment that John talk
    > > about
    > > i forgot the part MsForms.TextBox.
    > > Now i have all the textboxes grouped...
    > > the question is....i try instead of command_click the
    > > private Sub TextBoxGroup_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    > > --here i have the code
    > > end sub
    > >
    > > but it never enters here,can you help me?
    > > thanks
    > > Miguel
    > >
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Private Sub TextBox1_Change()
    > > > myCommonMacro
    > > > End Sub
    > > >
    > > >
    > > > etc., or else youy can modify John Walkenbach's technique shown here
    > > > http://j-walk.com/ss/excel/tips/tip44.htm
    > > >
    > > > --
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > "Liedson31" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > hi everyone.
    > > > >
    > > > > i have a function that i want to run everytime the user change a value
    > > > from
    > > > > all textboxes included on a form. i don´t want to put code on every
    > > > > textbox,i´m asking if is that any way that once the user input a value

    > on
    > > > one
    > > > > textbox i run a function.have the forms a change event or similar that

    > let
    > > > me
    > > > > do this?
    > > > >
    > > > > thanks in advance
    > > > > Miguel
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1