Consulting

Results 1 to 7 of 7

Thread: Using option button properties

  1. #1
    VBAX Regular
    Joined
    Oct 2007
    Posts
    13
    Location

    Using option button properties

    I am trying to get the code to hook together the caption property values for the various combo boxes selected and display the string of text in a cell. I have gotten it to get the first optionbutton caption value and put it where I want it (Thanks to xld's help), but I have multiple groups of optionbuttons and can't figure out how to get it to read the subsequent optionbuttons. I have attached the file so you can see it. Thanks for your help.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    The following code is only an adaptation of a snippet of your own without the 'Exit For' line to allow it to run through ALL the option buttons on the form. I've not taken the time to look into this in any depth:
    [vba]summat = ""
    For Each ctl In Me.Controls
    If TypeName(ctl) = "OptionButton" Then
    If ctl.Value Then summat = summat & "|" & ctl.Caption
    End If
    Next ctl[/vba]After this has run, 'summat' contains the likes of
    "|Wells Fargo|Transfer|Checking"
    I know it may not be in the right order vis-a-vis the user form, but you can further manipulate the text to your heart's content.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Oct 2007
    Posts
    13
    Location
    Thanks for that code, I got it to work, but I can't rearrange the order of how it pulls the Caption value, any tips on how to get it to be in this order: Transfer|Wells Fargo|Checking? Thanks again.

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    but you can further manipulate the text to your heart's content
    tack this snippet on:
    [vba]summatelse = Split(summat, "|")
    summat = summatelse(1) & "|" & summatelse(3) & "|" & summatelse(2)
    [/vba]The order is determined by the
    For Each ctl In Me.Controls
    line, which probably goes through them in the order they were added to the form.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Regular
    Joined
    Oct 2007
    Posts
    13
    Location
    Where should I put that code? I can't get it to work. Thanks for your help, I really appreciate it.

  6. #6
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    straight after the snippet in message #2

    Oops, I assumed left to right as on the form, so change
    [VBA]summat = summatelse(1) & "|" & summatelse(3) & "|" & summatelse(2)[/VBA]
    to
    [VBA] summat = summatelse(2) & "|" & summatelse(1) & "|" & summatelse(3)[/VBA]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  7. #7
    VBAX Regular
    Joined
    Oct 2007
    Posts
    13
    Location
    Thanks for your help, it is working great.

Posting Permissions

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