Probably a better way to handle database edits (at least in VBA Code) is using a With code block like this (I've highlighted the changes):
Code:
Private Sub coAcceptData_Click()
On Error GoTo Err_coAcceptData_Click
Dim EmpNumber, EmpFname, EmpLname, EmpPosition, EmpRate As String
Dim EmpHrs, EmpMins As Integer
Dim EmpDate As Date
Dim tbWOEmployee As DAO.Database
Dim rstWOEmployee As DAO.Recordset
Set tbWOEmployee = CurrentDb
Set rstWOEmployee = tbWOEmployee.OpenRecordset("tbWOEmployee", dbOpenDynaset)
If strEditLab = "EditLab" Then
rstWOEmployee.FindFirst "[WOEmpRec] = " & strDeleteRecNo & ""
If rstWOEmployee.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
With rstWOEmployee
.Edit ' Can also have .Delete and .AddNew here!
!WOEmpDate = Me.cbDate ' Database fields are always prefixed with a "bang" (!) character.
.Update ' Always have this as the last statement in a With block
.Bookmark = .LastModified
End With
Me.Refresh
End If
Me.txTradeName.Visible = False
Me.cbTradeName.Visible = True
Me.Label21.Visible = False
Me.cbTradeName_Label.Visible = True
Me.cbDate = ""
Me.txHours = ""
Me.txMins = ""
strEditLab = ""
Me.Refresh
Else
EmpNumber = Me.cbTradeName.Column(0)
EmpFname = Me.cbTradeName.Column(1)
EmpLname = Me.cbTradeName.Column(2)
EmpPosition = Me.cbTradeName.Column(3)
EmpRate = Me.cbTradeName.Column(4)
EmpDate = Me.cbDate
EmpHrs = Me.txHours
EmpMins = Me.txMins
With rstWOEmployee
.AddNew
!WONumber = strWOLabMat
!EmployeeID = EmpNumber
!FirstName = EmpFname
!LastName = EmpLname
!Position = EmpPosition
!Rate = EmpRate
!WOEmpDate = EmpDate
!WOHours = EmpHrs
!WOMinutes = EmpMins
.Update
.Bookmark = .LastModified
End With
Me.Refresh
Me.cbTradeName.SetFocus
End If
Exit_coAcceptData_Click:
rstWOEmployee.Close
Set rstWOEmployee = Nothing
Set tbWOEmployee = Nothing
Exit Sub
Err_coAcceptData_Click:
MsgBox Err.Description
Resume Exit_coAcceptData_Click
I noticed you use a couple of variables in your function that aren't set anywhere: strEditLab and strWOLabMat. I'm hoping that these variables are just assigned outside the function, but I thought I'd better mention it just in case