Results 1 to 7 of 7

userform default option button

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    userform default option button

    when i open this userform the option buttons default to "no"....when i click the ADD PROJECT button my the code does not recognize that the option buttons are selected on "no"...unless i toggle them prior to pushing ADD PROJECT.

    here is the add project code: (sample form attached)

    Private Sub cmdAdd_Click()
    Dim LRow As Long
    Dim lPart As Long
    Dim ws As Worksheet
    Set ws = Worksheets("PROJECTS")
    
    'find first empty row in database
    LRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
    
    lPart = Me.cmbTYPE.ListIndex
    
    'check for a part number
    If Trim(Me.jobno.Value) = "" Then
      Me.jobno.SetFocus
      MsgBox "ENTER JOB NUMBER"
      Exit Sub
    End If
    
    Dim JobNum As Range
    Set JobNum = ws.Range("C1:C" & LRow).Find(What:=Me.jobno, SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues)
    
    If JobNum Is Nothing Then
        'rest of code to push to sheet.
    Else
        MsgBox "JOB NUMBER ALREADY ENTERED"
        
    Exit Sub
    End If
    
    'copy the data to the database
    'use protect and unprotect lines,
    '     with your password
    '     if worksheet is protected
    With ws
      .Cells(LRow, 2).Value = Me.cmbTYPE.Value
      .Cells(LRow, 3).Value = Me.jobno.Value
      .Cells(LRow, 4).Value = Me.jobname.Value
      .Cells(LRow, 5).Value = Me.state.Value
      .Cells(LRow, 6).Value = Me.town.Value
      .Cells(LRow, 7).Value = Me.dateentered.Value
      .Cells(LRow, 8).Value = Me.cmbPa.Value
      .Cells(LRow, 9).Value = Me.cmbPm.Value
      .Cells(LRow, 11).Value = Me.arcode.Value
      .Cells(LRow, 12).Value = Me.billto.Value
      .Cells(LRow, 13).Value = Me.contract.Value
    
      .Cells(LRow, 15).Value = Me.reqdue.Value
      .Cells(LRow, 16).Value = Me.cmbStatus.Value
      .Cells(LRow, 17).Value = Me.notes.Value
      .Cells(LRow, 32).Value = Me.billingnotes.Value
      
    End With
    
    'clear the data
    Me.cmbTYPE.Value = ""
    Me.jobno.Value = ""
    Me.jobname.Value = ""
    Me.state.Value = ""
    Me.town.Value = ""
    Me.cmbPa.Value = ""
    Me.cmbPm.Value = ""
    Me.arcode.Value = ""
    Me.billto.Value = ""
    Me.contract.Value = ""
    
    Me.reqdue.Value = ""
    Me.cmbStatus.Value = ""
    Me.notes.Value = ""
    
    Exit Sub
    
      
    If ocipyes.Value = True Then
        ws.Cells(UpdateRow, 14).Value = "1"
    Else
        ws.Cells(UpdateRow, 14).Value = "0"
    End If
    
    If budgetyes.Value = True Then
        ws.Cells(UpdateRow, 19).Value = "1"
    Else
        ws.Cells(UpdateRow, 19).Value = "0"
    End If
    
    If sovyes.Value = True Then
        ws.Cells(UpdateRow, 20).Value = "1"
    Else
        ws.Cells(UpdateRow, 20).Value = "0"
    End If
    
    If bondyes.Value = True Then
        ws.Cells(UpdateRow, 21).Value = "1"
    Else
        ws.Cells(UpdateRow, 21).Value = "0"
    End If
    
    If estyes.Value = True Then
        ws.Cells(UpdateRow, 22).Value = "1"
    Else
        ws.Cells(UpdateRow, 22).Value = "0"
    End If
    
    If paulyes.Value = True Then
        ws.Cells(UpdateRow, 23).Value = "1"
    Else
        ws.Cells(UpdateRow, 23).Value = "0"
    End If
    
    If steveyes.Value = True Then
        ws.Cells(UpdateRow, 24).Value = "1"
    Else
        ws.Cells(UpdateRow, 24).Value = "0"
    End If
    
    If pmyes.Value = True Then
        ws.Cells(UpdateRow, 25).Value = "1"
    Else
        ws.Cells(UpdateRow, 25).Value = "0"
    End If
        
        
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Userform: requiring fields and using a check box to set default option boxes
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2014, 10:07 AM
  2. UserForm Option Button Help...
    By z-eighty2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 10:17 PM
  3. Userform option button help
    By mecharissa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2012, 04:48 AM
  4. Userform Option Button to Show/Hide Another Option Button on same Userform
    By R_S_6 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2010, 09:44 AM
  5. Making an option button default
    By peedarp1985 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2010, 02:31 AM
  6. Default Option Button Values
    By maxwell13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2008, 06:03 PM
  7. Option Button as default
    By StephanieH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2005, 10:06 AM

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