Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: changing code from using Combobox to optionbuttons

  1. #11
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    My guess the best option would be to put them in 1 frame so you select either one of them. Otherwise you should put an extra button to enable both frames when you change your mind.

  2. #12
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    or give them the same 'groupname'

  3. #13
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks
    I did have a version where I placed all in the 1 frame...I am stilling working on it but it does work on some features.The issues I am having is if I select Internal and its selections from the combobox`s it works as it renders External combobox`s disabled.If i then change to External is keeps the selections in the combobox`s also from Internal so it ends up transferring both Internal and External combobox`s......if I select Internal and its combobox`s only it works fine......same for External

    I also have userform Production and Planned Stop now working

    How do I give the same Groupname.....is this in properties?

    Thanks
    Attached Files Attached Files

  4. #14
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Combobox issue resolved.
    Attached Files Attached Files

  5. #15
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks bakerman
    Works....if i select Internal or External can the Time textbox`s also be disabled (entry deleted) on the 1 not selected.
    If changing from say Internal to External it removes the entries in the Combobox`s but not the Textbox.......i will attempt to resolve this so would i need to add code in the Optionbutton4 and 5 parts of the code

    Thanks again

  6. #16
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Try it this way.

    Code:
    Private Sub OptionButton4_Click()
    
        For i = 2 To 6
            With Me("Combobox" & i)
                .Value = vbNullString
                .Enabled = IIf(i <= 4, True, False)
            End With
            If i = 2 Or i = 3 Then
                With Me("Textbox" & i)
                    .Text = vbNullString
                    .Enabled = IIf(i = 2, True, False)
                End With
            End If
        Next
        
    End Sub
    
    Private Sub OptionButton5_Click()
    
        For i = 2 To 6
            With Me("Combobox" & i)
                .Value = vbNullString
                .Enabled = IIf(i <= 4, False, True)
            End With
            If i = 2 Or i = 3 Then
                With Me("Textbox" & i)
                    .Text = vbNullString
                    .Enabled = IIf(i <> 3, False, True)
                End With
            End If
        Next
        
    End Sub

  7. #17
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks for all your help bakerman...the code above worked

    I did find 2 errors...i used the Tag property in the userform for the Combobox`s and Textbox`s and they work...i used the Tag Property for the Optionbuttons for XFLOW A+B+C also but if i transfer the userform without selecting XFLOW A or B or C it gives a Runtime error...i thought the Tag property would stop this error...

    Also if i do not select External or Internal i can then select all the Combobox`s and Textbox`s in the frame......is there a way to force either Internal or External to be selected

    Thanks

    Paul
    Last edited by paul_pearson; 09-04-2013 at 04:06 PM.

  8. #18
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    1) Remove the Tags from XFLOW A+B+C and put next code on top of CommandButton1_Click.
    Code:
        For Each ctl In Frame1.Controls
            If TypeName(ctl) = "OptionButton" Then
                If ctl.Value = False Then x = x + 1
            End If
        Next
        If x = 3 Then MsgBox "Select a machine before you write data": Exit Sub
    2) In designmode set the Enabled-property of the CB's and both TB's to False.

  9. #19
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks bakerman
    Added the code (possibly in the wrong place) and set the Enabled-property of the CB's and both TB's to False

    If i select date and machine and press Transfer Button it messagebox says "Select a Part"...i press OK and it give a Runtime Error 2110.....

    Could this be where i placed the code as you mentioned on top of CommandButton1_Click...i could not get it to place above the CommandButton1_Click which may cause the error

    Thanks again
    Attached Files Attached Files

  10. #20
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Change this line
    Code:
    If ctl.Value = vbNullString Then MsgBox ctl.Tag: ctl.SetFocus: Exit Sub
    to this line
    Code:
    If ctl.Value = vbNullString Then MsgBox ctl.Tag: Exit Sub
    The error occured because you can't set focus to a disabled object.

Similar Threads

  1. Replies: 8
    Last Post: 08-17-2013, 04:03 AM
  2. Changing Picture Using Data Validation
    By jeff in forum Excel Help
    Replies: 3
    Last Post: 08-03-2013, 09:39 AM
  3. adding entries into combobox with code
    By paul_pearson in forum Excel Help
    Replies: 1
    Last Post: 07-23-2013, 01:01 PM
  4. Changing Slideshow viewing mode to kiosk using vba
    By Times in forum Powerpoint Help
    Replies: 1
    Last Post: 05-10-2013, 12:37 AM
  5. Changing Hyperlink To Another Sheet By Changing Value Of Cell
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 04-30-2011, 11:55 PM

Posting Permissions

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