Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: changing code from using Combobox to optionbuttons

  1. #21
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks bakerman

    That solved.....no error but if i select External and it combobox`s ,fill in a comment and then Transfer Data a messagebox asks for me to select a Part which is disabled in the Internal section......would this be from Tags in the properties....if i remove this this it will not be available when i select Internal option

    It works fine if i select the Internal option as it transfers the data correctly,it is only if i select External this happens

    Thanks again

  2. #22
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    This covers all, i guess.
    Attached Files Attached Files

  3. #23
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks again bakerman

    All works well and i guess you are most likely getting tired of this thread but 1 last go

    If i enter a date and machine i can send data without it having all the fields with entries....it only asks for a Comment....

    If this can be changed i think it is finally finished

    Thanks again

  4. #24
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Code:
    Private Sub CommandButton1_Click()
    
        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
        For Each ctl In Frame2.Controls
            If TypeName(ctl) = "OptionButton" Then
                If ctl.Value = False Then y = y + 1
            End If
        Next
        If y = 2 Then MsgBox "Select Internal or External before you write data": Exit Sub
        'check user input
        For Each ctl In Me.Controls
            If ctl.Tag <> vbNullString And ctl.Enabled Then
                If ctl.Value = vbNullString Then MsgBox ctl.Tag: Exit Sub
            End If
        Next
        For i = 1 To 3
            If Me("OptionButton" & i) Then whatsheet = Me("OptionButton" & i).Caption
        Next
        'write data to worksheet
        With Sheets(whatsheet)
           .Unprotect Password:="abc"
           .Cells(.Cells(.Rows.Count, "B").End(xlUp).Row + 1, 2).Resize(, 17) = Array(ComboBox1.Value, , , , , , , , _
                ComboBox2.Value, ComboBox3.Value, ComboBox4.Value, TextBox2.Text, IIf(OptionButton4, TextBox1.Text, ""), _
                ComboBox5.Value, ComboBox6.Value, TextBox3.Text, IIf(OptionButton5, TextBox1.Text, ""))
            .Protect Password:="abc"
        End With
        'Clear all fields
        For Each ctl In Me.Controls
            If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = vbNullString
            If TypeName(ctl) = "OptionButton" Then ctl.Value = False
        Next
        For i = 2 To 6
            Me("Combobox" & i).Enabled = False
            If i = 2 Or i = 3 Then Me("Textbox" & i).Enabled = False
        Next
        End Sub

  5. #25
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Thanks bakerman for all your help....appreciated

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
  •