Hello,
I have a userform which requires data to be entered for every textbox on the userform. I want to make it to where its acceptable for two of the text boxes the user only has to enter data into one of the two textboxes. AKA the user cannot leave the two text boxes blank, cannot enter information into both textboxes, but must enter data into one of the two textboxes.
Private Sub cmdadd_click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Repair Log")
If Me.txtdaafp.Text = Empty Then
MsgBox "Please enter DAA FP #.", vbExclamation
Me.txtdaafp.SetFocus
Exit Sub
End If
If Me.txtorder.Text = Empty Then
MsgBox "Please enter Order #.", vbExclamation
Me.txtorder.SetFocus
Exit Sub
End If
If Me.txtdate.Text = Empty Then
MsgBox "Please select date.", vbExclamation
Me.txtdate.SetFocus
Exit Sub
End If
If Me.txttime.Text = Empty Then
MsgBox "Please enter time spent in minutes.", vbExclamation
Me.txttime.SetFocus
Exit Sub
End If
If Me.txtquant.Text = Empty Then
MsgBox "Please enter quantity of parts repaired.", vbExclamation
Me.txtquant.SetFocus
Exit Sub
End If
If Me.txtrworg.Text = Empty Then
MsgBox "Please enter your org. #.", vbExclamation
Me.txtrworg.SetFocus
Exit Sub
End If
If Me.txttlorg.Text = Empty Then
MsgBox "Please enter org # of T.L./Supervisor who approved part.", vbExclamation
Me.txttlorg.SetFocus
Exit Sub
End If
If Me.cbomat.Text = Empty Then
MsgBox "Please select material from the drop down box.", vbExclamation
Me.cbomat.SetFocus
Exit Sub
End If
If Me.cbodc.Text = Empty Then
MsgBox "Please select defect code from drop down box.", vbExclamation
Me.cbodc.SetFocus
Exit Sub
End If
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
With ws
.Cells(iRow, 1).Value = Me.txtdaafp.Value
.Cells(iRow, 2).Value = Me.txtorder.Value
.Cells(iRow, 3).Value = Me.txtdate.Value
.Cells(iRow, 4).Value = Me.txttime.Value
.Cells(iRow, 5).Value = Me.txtquant.Value
.Cells(iRow, 6).Value = Me.txtrworg.Value
.Cells(iRow, 7).Value = Me.txttlorg.Value
.Cells(iRow, 8).Value = Me.cbomat.Text
.Cells(iRow, 9).Value = Me.cbodc.Text
Me.txtdaafp.Text = Empty
Me.txtorder.Text = Empty
Me.txtdate.Text = Empty
Me.txttime.Text = Empty
Me.txtquant.Text = Empty
Me.txtrworg.Text = Empty
Me.txttlorg.Text = Empty
Me.cbomat.Text = Empty
Me.cbodc.Text = Empty
Me.txtdaafp.SetFocus
End With
End Sub
the two I want the user to select from are txtdaafp and txtorder.
Thanks
Bookmarks