jcaptchaos2
Well-known Member
- Joined
- Sep 24, 2002
- Messages
- 1,032
- Office Version
- 365
- Platform
- Windows
I am not sure what I did to this code but now I am getting an error "Block If without end if" Could someone take a look to see if it's something obvious.
Thanks
Thanks
Code:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a Employee number
If Trim(Me.txtempl.Value) = "" Then
Me.txtempl.SetFocus
MsgBox "Please enter a Employee Number"
Exit Sub
End If
'check for a Item number
If Trim(Me.txtitemno.Value) = "" Then
Me.txtitemno.SetFocus
MsgBox "Please enter a Item Number"
Exit Sub
End If
'check for a Shop Order number
If Trim(Me.txtshop.Value) = "" Then
Me.txtshop.SetFocus
MsgBox "Please enter a Shop Order Number"
Exit Sub
End If
'check for a Operation number
If Trim(Me.txtopno.Value) = "" Then
Me.txtopno.SetFocus
MsgBox "Please enter a Operation Number"
Exit Sub
'copy the data to the database
With ws
.Cells(iRow, 1).Value = Me.txtempl.Value
.Cells(iRow, 2).Value = Me.txtitemno.Value
.Cells(iRow, 3).Value = Me.txtshop.Value
.Cells(iRow, 4).Value = Me.txtopno.Value
.Cells(iRow, 5).Value = Me.txtgood.Value
.Cells(iRow, 6).Value = Me.txtscrapqty.Value
.Cells(iRow, 7).Value = Me.txtscrapcode.Value
.Cells(iRow, 8).Value = Me.txtstart.Value
.Cells(iRow, 9).Value = Time
.Cells(iRow, 10).Value = Date
End With
'clear the data
Me.txtempl.Value = ""
Me.txtitemno.Value = ""
Me.txtshop.Value = ""
Me.txtopno.Value = ""
Me.txtgood.Value = ""
Me.txtscrapqty.Value = ""
Me.txtscrapcode.Value = ""
Me.txtstart.Value = ""
Me.txtempl.SetFocus
End Sub