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
Bookmarks