keiserj
Board Regular
- Joined
- May 31, 2013
- Messages
- 89
Below is the code for a userform that im working on. But have str1 & str2 combining but if the user does not select str1 which is a list box it comes up a error. any way around this?
Code:
Private Sub CommandButton1_Click()
Dim RowCount As Long
Dim ctl As Control
Dim str1 As String
Dim str2 As String
If Me.textpartnum.Value = "" Then
MsgBox "Please enter a PART #.", vbExclamation, "Missing Parts Form"
Me.textpartnum.SetFocus
Exit Sub
End If
If Me.Textmachinenum.Value = "" Then
MsgBox "Please enter a Machine #.", vbExclamation, "Missing Parts Form"
Me.Textmachinenum.SetFocus
Exit Sub
End If
If Me.ListBox1.Value = "" Then
MsgBox "Please select MFG or Purch.", vbExclamation, "Missing Parts Form"
Me.ListBox1.SetFocus
Exit Sub
End If
str1 = Me.ListBox1.Value
str2 = Format(Now, "mmddyyhhnnss")
RowCount = Worksheets("Missing Part Log").Range("A3").CurrentRegion.Rows.Count
With Worksheets("Missing Part Log").Range("A3")
.Offset(RowCount, 0).Value = str1 & str2
.Offset(RowCount, 1).Value = Me.textpartnum.Value
.Offset(RowCount, 2).Value = Me.textQTYNEED.Value
.Offset(RowCount, 3).Value = Me.ListBox1.Value
.Offset(RowCount, 4).Value = Me.ComboBox1.Value
.Offset(RowCount, 5).Value = Me.textmfgdate.Value
.Offset(RowCount, 6).Value = Me.Textrecdate.Value
.Offset(RowCount, 7).Value = Me.Textmachinenum.Value
.Offset(RowCount, 8).Value = Me.Textsonum.Value
.Offset(RowCount, 9).Value = Me.Textcopnum.Value
.Offset(RowCount, 10).Value = Me.Textbuilddate.Value
Call resetForm
End With
End Sub