+ Reply to Thread
Results 1 to 12 of 12

Change properties of a userform

  1. #1
    Mike Archer
    Guest

    Change properties of a userform

    Hello -
    How do you programically change an optionbutton value permenatly. I want
    the default value for an option button to be true every time the userform is
    ran after the user selects that optionbutton. I thought that you could just
    set it to true when it was checked... Like this:

    Private Sub OptionButton1_Click()
    Me.OptionButton1.Value = True
    End Sub

    Private Sub OptionButton2_Click()
    Me.OptionButton2.Value = True
    End Sub

    Private Sub OptionButton3_Click()
    Me.OptionButton3.Value = True
    End Sub

    But it always goes back to the one that I set to true in the properties.
    It's probably easy, but I can't figure it out (other than storing the
    selection on the workbook and referencing it in the initialization event -
    pretty sloppy, I know).

    --
    Thanks,
    Mike

  2. #2
    Ardus Petus
    Guest

    Re: Change properties of a userform

    Option buttons are mutually exclusive.
    There is only one of them you can set to TRUE.


    Private Sub UserForm_Activate()
    Me.OptionButton1.Value = True
    End Sub

    HTH
    --
    AP

    "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le message
    de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    > Hello -
    > How do you programically change an optionbutton value permenatly. I want
    > the default value for an option button to be true every time the userform
    > is
    > ran after the user selects that optionbutton. I thought that you could
    > just
    > set it to true when it was checked... Like this:
    >
    > Private Sub OptionButton1_Click()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > Private Sub OptionButton2_Click()
    > Me.OptionButton2.Value = True
    > End Sub
    >
    > Private Sub OptionButton3_Click()
    > Me.OptionButton3.Value = True
    > End Sub
    >
    > But it always goes back to the one that I set to true in the properties.
    > It's probably easy, but I can't figure it out (other than storing the
    > selection on the workbook and referencing it in the initialization event -
    > pretty sloppy, I know).
    >
    > --
    > Thanks,
    > Mike




  3. #3
    Ivan Raiminius
    Guest

    Re: Change properties of a userform

    Hi Mike,

    maybe I didn't understand your question, but you don't need to use:
    Private Sub OptionButton1_Click()
    Me.OptionButton1.Value = True
    End Sub
    to change the value of optionbutton. It changes automatically,
    including unchecking all the other optionbuttons in the same
    form/tab/frame.

    If you need to set value of the optionbutton before you show the
    userform to the user, use something like this:
    with userform
    ..optionbutton1.value=true 'sets the default = checked optionbutton1
    ..show
    end with

    Regards,
    Ivan

    Mike Archer wrote:
    > Hello -
    > How do you programically change an optionbutton value permenatly. I want
    > the default value for an option button to be true every time the userform is
    > ran after the user selects that optionbutton. I thought that you could just
    > set it to true when it was checked... Like this:
    >
    > Private Sub OptionButton1_Click()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > Private Sub OptionButton2_Click()
    > Me.OptionButton2.Value = True
    > End Sub
    >
    > Private Sub OptionButton3_Click()
    > Me.OptionButton3.Value = True
    > End Sub
    >
    > But it always goes back to the one that I set to true in the properties.
    > It's probably easy, but I can't figure it out (other than storing the
    > selection on the workbook and referencing it in the initialization event -
    > pretty sloppy, I know).
    >
    > --
    > Thanks,
    > Mike



  4. #4
    Mike Archer
    Guest

    RE: Change properties of a userform

    Thanks to both of you for answering. I didn't present my question very
    clearly. Basically I want the user to select an optionbutton and then for
    that optionbutton to still be true the next time the userform runs.
    --
    Thanks,
    Mike


    "Mike Archer" wrote:

    > Hello -
    > How do you programically change an optionbutton value permenatly. I want
    > the default value for an option button to be true every time the userform is
    > ran after the user selects that optionbutton. I thought that you could just
    > set it to true when it was checked... Like this:
    >
    > Private Sub OptionButton1_Click()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > Private Sub OptionButton2_Click()
    > Me.OptionButton2.Value = True
    > End Sub
    >
    > Private Sub OptionButton3_Click()
    > Me.OptionButton3.Value = True
    > End Sub
    >
    > But it always goes back to the one that I set to true in the properties.
    > It's probably easy, but I can't figure it out (other than storing the
    > selection on the workbook and referencing it in the initialization event -
    > pretty sloppy, I know).
    >
    > --
    > Thanks,
    > Mike


  5. #5
    Ardus Petus
    Guest

    Re: Change properties of a userform

    I reiterate my solution:

    Private Sub UserForm_Activate()
    Me.OptionButton1.Value = True
    End Sub

    HTH
    --
    AP

    "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le message
    de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    > Hello -
    > How do you programically change an optionbutton value permenatly. I want
    > the default value for an option button to be true every time the userform
    > is
    > ran after the user selects that optionbutton. I thought that you could
    > just
    > set it to true when it was checked... Like this:
    >
    > Private Sub OptionButton1_Click()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > Private Sub OptionButton2_Click()
    > Me.OptionButton2.Value = True
    > End Sub
    >
    > Private Sub OptionButton3_Click()
    > Me.OptionButton3.Value = True
    > End Sub
    >
    > But it always goes back to the one that I set to true in the properties.
    > It's probably easy, but I can't figure it out (other than storing the
    > selection on the workbook and referencing it in the initialization event -
    > pretty sloppy, I know).
    >
    > --
    > Thanks,
    > Mike




  6. #6
    Mike Archer
    Guest

    Re: Change properties of a userform

    I must be missing something. How do I know which one to set to true in the
    activate event. If the user checked optionbutton3 the last time the form was
    ran, I want optiongbutton3 to be true everytime the form is ran until another
    optionbutton is checked.
    --
    Thanks,
    Mike


    "Ardus Petus" wrote:

    > I reiterate my solution:
    >
    > Private Sub UserForm_Activate()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > HTH
    > --
    > AP
    >
    > "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le message
    > de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    > > Hello -
    > > How do you programically change an optionbutton value permenatly. I want
    > > the default value for an option button to be true every time the userform
    > > is
    > > ran after the user selects that optionbutton. I thought that you could
    > > just
    > > set it to true when it was checked... Like this:
    > >
    > > Private Sub OptionButton1_Click()
    > > Me.OptionButton1.Value = True
    > > End Sub
    > >
    > > Private Sub OptionButton2_Click()
    > > Me.OptionButton2.Value = True
    > > End Sub
    > >
    > > Private Sub OptionButton3_Click()
    > > Me.OptionButton3.Value = True
    > > End Sub
    > >
    > > But it always goes back to the one that I set to true in the properties.
    > > It's probably easy, but I can't figure it out (other than storing the
    > > selection on the workbook and referencing it in the initialization event -
    > > pretty sloppy, I know).
    > >
    > > --
    > > Thanks,
    > > Mike

    >
    >
    >


  7. #7
    Ardus Petus
    Guest

    Re: Change properties of a userform

    You must link each optionbutton to a specific cell via ControlSource
    property (eg: Sheet1!A1)

    This way, Excel will show the current selected optionbutton when you run
    Userform1.Show

    HTH
    --
    AP

    "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le message
    de news: 966C40B4-82B3-4A5C-8F90-76962D1A81D3@microsoft.com...
    >I must be missing something. How do I know which one to set to true in the
    > activate event. If the user checked optionbutton3 the last time the form
    > was
    > ran, I want optiongbutton3 to be true everytime the form is ran until
    > another
    > optionbutton is checked.
    > --
    > Thanks,
    > Mike
    >
    >
    > "Ardus Petus" wrote:
    >
    >> I reiterate my solution:
    >>
    >> Private Sub UserForm_Activate()
    >> Me.OptionButton1.Value = True
    >> End Sub
    >>
    >> HTH
    >> --
    >> AP
    >>
    >> "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le
    >> message
    >> de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    >> > Hello -
    >> > How do you programically change an optionbutton value permenatly. I
    >> > want
    >> > the default value for an option button to be true every time the
    >> > userform
    >> > is
    >> > ran after the user selects that optionbutton. I thought that you could
    >> > just
    >> > set it to true when it was checked... Like this:
    >> >
    >> > Private Sub OptionButton1_Click()
    >> > Me.OptionButton1.Value = True
    >> > End Sub
    >> >
    >> > Private Sub OptionButton2_Click()
    >> > Me.OptionButton2.Value = True
    >> > End Sub
    >> >
    >> > Private Sub OptionButton3_Click()
    >> > Me.OptionButton3.Value = True
    >> > End Sub
    >> >
    >> > But it always goes back to the one that I set to true in the
    >> > properties.
    >> > It's probably easy, but I can't figure it out (other than storing the
    >> > selection on the workbook and referencing it in the initialization
    >> > event -
    >> > pretty sloppy, I know).
    >> >
    >> > --
    >> > Thanks,
    >> > Mike

    >>
    >>
    >>




  8. #8
    Ardus Petus
    Guest

    Re: Change properties of a userform

    You must link each optionbutton to a specific cell via ControlSource
    property (eg: Sheet1!A1)

    This way, Excel will show the current selected optionbutton when you run
    Userform1.Show

    HTH
    --
    AP

    "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le message
    de news: 966C40B4-82B3-4A5C-8F90-76962D1A81D3@microsoft.com...
    >I must be missing something. How do I know which one to set to true in the
    > activate event. If the user checked optionbutton3 the last time the form
    > was
    > ran, I want optiongbutton3 to be true everytime the form is ran until
    > another
    > optionbutton is checked.
    > --
    > Thanks,
    > Mike
    >
    >
    > "Ardus Petus" wrote:
    >
    >> I reiterate my solution:
    >>
    >> Private Sub UserForm_Activate()
    >> Me.OptionButton1.Value = True
    >> End Sub
    >>
    >> HTH
    >> --
    >> AP
    >>
    >> "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le
    >> message
    >> de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    >> > Hello -
    >> > How do you programically change an optionbutton value permenatly. I
    >> > want
    >> > the default value for an option button to be true every time the
    >> > userform
    >> > is
    >> > ran after the user selects that optionbutton. I thought that you could
    >> > just
    >> > set it to true when it was checked... Like this:
    >> >
    >> > Private Sub OptionButton1_Click()
    >> > Me.OptionButton1.Value = True
    >> > End Sub
    >> >
    >> > Private Sub OptionButton2_Click()
    >> > Me.OptionButton2.Value = True
    >> > End Sub
    >> >
    >> > Private Sub OptionButton3_Click()
    >> > Me.OptionButton3.Value = True
    >> > End Sub
    >> >
    >> > But it always goes back to the one that I set to true in the
    >> > properties.
    >> > It's probably easy, but I can't figure it out (other than storing the
    >> > selection on the workbook and referencing it in the initialization
    >> > event -
    >> > pretty sloppy, I know).
    >> >
    >> > --
    >> > Thanks,
    >> > Mike

    >>
    >>
    >>




  9. #9
    Ardus Petus
    Guest

    Re: Change properties of a userform

    You must link each optionbutton to a specific cell via ControlSource
    property (eg: Sheet1!A1)

    This way, Excel will show the current selected optionbutton when you run
    Userform1.Show

    HTH
    --
    AP

    "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le message
    de news: 966C40B4-82B3-4A5C-8F90-76962D1A81D3@microsoft.com...
    >I must be missing something. How do I know which one to set to true in the
    > activate event. If the user checked optionbutton3 the last time the form
    > was
    > ran, I want optiongbutton3 to be true everytime the form is ran until
    > another
    > optionbutton is checked.
    > --
    > Thanks,
    > Mike
    >
    >
    > "Ardus Petus" wrote:
    >
    >> I reiterate my solution:
    >>
    >> Private Sub UserForm_Activate()
    >> Me.OptionButton1.Value = True
    >> End Sub
    >>
    >> HTH
    >> --
    >> AP
    >>
    >> "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le
    >> message
    >> de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    >> > Hello -
    >> > How do you programically change an optionbutton value permenatly. I
    >> > want
    >> > the default value for an option button to be true every time the
    >> > userform
    >> > is
    >> > ran after the user selects that optionbutton. I thought that you could
    >> > just
    >> > set it to true when it was checked... Like this:
    >> >
    >> > Private Sub OptionButton1_Click()
    >> > Me.OptionButton1.Value = True
    >> > End Sub
    >> >
    >> > Private Sub OptionButton2_Click()
    >> > Me.OptionButton2.Value = True
    >> > End Sub
    >> >
    >> > Private Sub OptionButton3_Click()
    >> > Me.OptionButton3.Value = True
    >> > End Sub
    >> >
    >> > But it always goes back to the one that I set to true in the
    >> > properties.
    >> > It's probably easy, but I can't figure it out (other than storing the
    >> > selection on the workbook and referencing it in the initialization
    >> > event -
    >> > pretty sloppy, I know).
    >> >
    >> > --
    >> > Thanks,
    >> > Mike

    >>
    >>
    >>




  10. #10
    Harald Staff
    Guest

    Re: Change properties of a userform

    Hi Mike

    You need to remember the selected options somewhere between the userform
    sessions. You could write something to an external textfile, to a hidden
    worksheet, or to the registry. The latter selections follows the user, not
    the application, so it's the preferred "userfriendly" way to do it. Have a
    look at SaveSetting and GetSetting in help for registry entries /readings.

    HTH. Best wishes Harald

    "Mike Archer" <MikeArcher@discussions.microsoft.com> skrev i melding
    news:966C40B4-82B3-4A5C-8F90-76962D1A81D3@microsoft.com...
    > I must be missing something. How do I know which one to set to true in

    the
    > activate event. If the user checked optionbutton3 the last time the form

    was
    > ran, I want optiongbutton3 to be true everytime the form is ran until

    another
    > optionbutton is checked.
    > --
    > Thanks,
    > Mike
    >
    >
    > "Ardus Petus" wrote:
    >
    > > I reiterate my solution:
    > >
    > > Private Sub UserForm_Activate()
    > > Me.OptionButton1.Value = True
    > > End Sub
    > >
    > > HTH
    > > --
    > > AP
    > >
    > > "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le

    message
    > > de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    > > > Hello -
    > > > How do you programically change an optionbutton value permenatly. I

    want
    > > > the default value for an option button to be true every time the

    userform
    > > > is
    > > > ran after the user selects that optionbutton. I thought that you

    could
    > > > just
    > > > set it to true when it was checked... Like this:
    > > >
    > > > Private Sub OptionButton1_Click()
    > > > Me.OptionButton1.Value = True
    > > > End Sub
    > > >
    > > > Private Sub OptionButton2_Click()
    > > > Me.OptionButton2.Value = True
    > > > End Sub
    > > >
    > > > Private Sub OptionButton3_Click()
    > > > Me.OptionButton3.Value = True
    > > > End Sub
    > > >
    > > > But it always goes back to the one that I set to true in the

    properties.
    > > > It's probably easy, but I can't figure it out (other than storing the
    > > > selection on the workbook and referencing it in the initialization

    event -
    > > > pretty sloppy, I know).
    > > >
    > > > --
    > > > Thanks,
    > > > Mike

    > >
    > >
    > >




  11. #11
    Mike Archer
    Guest

    Re: Change properties of a userform

    PERFECT!!!!!!!!
    --
    Thanks,
    Mike


    "Harald Staff" wrote:

    > Hi Mike
    >
    > You need to remember the selected options somewhere between the userform
    > sessions. You could write something to an external textfile, to a hidden
    > worksheet, or to the registry. The latter selections follows the user, not
    > the application, so it's the preferred "userfriendly" way to do it. Have a
    > look at SaveSetting and GetSetting in help for registry entries /readings.
    >
    > HTH. Best wishes Harald
    >
    > "Mike Archer" <MikeArcher@discussions.microsoft.com> skrev i melding
    > news:966C40B4-82B3-4A5C-8F90-76962D1A81D3@microsoft.com...
    > > I must be missing something. How do I know which one to set to true in

    > the
    > > activate event. If the user checked optionbutton3 the last time the form

    > was
    > > ran, I want optiongbutton3 to be true everytime the form is ran until

    > another
    > > optionbutton is checked.
    > > --
    > > Thanks,
    > > Mike
    > >
    > >
    > > "Ardus Petus" wrote:
    > >
    > > > I reiterate my solution:
    > > >
    > > > Private Sub UserForm_Activate()
    > > > Me.OptionButton1.Value = True
    > > > End Sub
    > > >
    > > > HTH
    > > > --
    > > > AP
    > > >
    > > > "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le

    > message
    > > > de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    > > > > Hello -
    > > > > How do you programically change an optionbutton value permenatly. I

    > want
    > > > > the default value for an option button to be true every time the

    > userform
    > > > > is
    > > > > ran after the user selects that optionbutton. I thought that you

    > could
    > > > > just
    > > > > set it to true when it was checked... Like this:
    > > > >
    > > > > Private Sub OptionButton1_Click()
    > > > > Me.OptionButton1.Value = True
    > > > > End Sub
    > > > >
    > > > > Private Sub OptionButton2_Click()
    > > > > Me.OptionButton2.Value = True
    > > > > End Sub
    > > > >
    > > > > Private Sub OptionButton3_Click()
    > > > > Me.OptionButton3.Value = True
    > > > > End Sub
    > > > >
    > > > > But it always goes back to the one that I set to true in the

    > properties.
    > > > > It's probably easy, but I can't figure it out (other than storing the
    > > > > selection on the workbook and referencing it in the initialization

    > event -
    > > > > pretty sloppy, I know).
    > > > >
    > > > > --
    > > > > Thanks,
    > > > > Mike
    > > >
    > > >
    > > >

    >
    >
    >


  12. #12
    Harald Staff
    Guest

    Re: Change properties of a userform

    You implemented it that fast ? Good work! Thanks for the feedback.

    Best wishes Harald

    "Mike Archer" <MikeArcher@discussions.microsoft.com> skrev i melding
    news:E6ED35AE-09BC-4C3C-A605-222D2A124292@microsoft.com...
    > PERFECT!!!!!!!!
    > --
    > Thanks,
    > Mike
    >
    >
    > "Harald Staff" wrote:
    >
    > > Hi Mike
    > >
    > > You need to remember the selected options somewhere between the userform
    > > sessions. You could write something to an external textfile, to a hidden
    > > worksheet, or to the registry. The latter selections follows the user,

    not
    > > the application, so it's the preferred "userfriendly" way to do it. Have

    a
    > > look at SaveSetting and GetSetting in help for registry entries

    /readings.
    > >
    > > HTH. Best wishes Harald
    > >
    > > "Mike Archer" <MikeArcher@discussions.microsoft.com> skrev i melding
    > > news:966C40B4-82B3-4A5C-8F90-76962D1A81D3@microsoft.com...
    > > > I must be missing something. How do I know which one to set to true

    in
    > > the
    > > > activate event. If the user checked optionbutton3 the last time the

    form
    > > was
    > > > ran, I want optiongbutton3 to be true everytime the form is ran until

    > > another
    > > > optionbutton is checked.
    > > > --
    > > > Thanks,
    > > > Mike
    > > >
    > > >
    > > > "Ardus Petus" wrote:
    > > >
    > > > > I reiterate my solution:
    > > > >
    > > > > Private Sub UserForm_Activate()
    > > > > Me.OptionButton1.Value = True
    > > > > End Sub
    > > > >
    > > > > HTH
    > > > > --
    > > > > AP
    > > > >
    > > > > "Mike Archer" <MikeArcher@discussions.microsoft.com> a écrit dans le

    > > message
    > > > > de news: 5DDCFD64-CD9B-4AA7-9C7B-42E73BFEB785@microsoft.com...
    > > > > > Hello -
    > > > > > How do you programically change an optionbutton value permenatly.

    I
    > > want
    > > > > > the default value for an option button to be true every time the

    > > userform
    > > > > > is
    > > > > > ran after the user selects that optionbutton. I thought that you

    > > could
    > > > > > just
    > > > > > set it to true when it was checked... Like this:
    > > > > >
    > > > > > Private Sub OptionButton1_Click()
    > > > > > Me.OptionButton1.Value = True
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub OptionButton2_Click()
    > > > > > Me.OptionButton2.Value = True
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub OptionButton3_Click()
    > > > > > Me.OptionButton3.Value = True
    > > > > > End Sub
    > > > > >
    > > > > > But it always goes back to the one that I set to true in the

    > > properties.
    > > > > > It's probably easy, but I can't figure it out (other than storing

    the
    > > > > > selection on the workbook and referencing it in the initialization

    > > event -
    > > > > > pretty sloppy, I know).
    > > > > >
    > > > > > --
    > > > > > Thanks,
    > > > > > Mike
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




+ 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