M
mrvento
Hi All,
I am in need of some help!!!
I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.
This is what I have:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("ECSProductionLog")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is>>>
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value
'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus
End Sub
I am in need of some help!!!
I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.
This is what I have:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("ECSProductionLog")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is>>>
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value
'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus
End Sub