Hello everyone -- Need some help. I am setting up an Access Database with employee information, here's the problem...I need to search for an EmployeeID and if it does not exist I need to add it, if it does exist I need certain fields on the form to autofill. It keeps crashing on the FindFirst statement...Here is my code
Any help I can get will be very much appreciated...Thanks!
CyndeQ
Code:
Private Sub ID_AfterUpdate()
Dim strAdd As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Employee Table";)
rst.FindFirst "[ID] = " & Me.ID.Value
If rst.NoMatch Then
'Add new employee information to database
rst.AddNew
rst![ID] = Me.ID.Value
rst![SocSecNo] = Me.txtSocSecNo.Value
rst![Craft] = Me.txtCraft.Value
rst![JobNo] = Me.txtJobNo.Value
rst![LastName] = Me.txtLastName.Value
rst![Suffix] = Me.txtSuffix.Value
rst![FirstName] = Me.txtFirstName.Value
rst![MiddleInitial] = Me.txtMiddleInitial.Value
rst![TWICCardNo] = Me.txtTWICCardNo.Value
rst![TWICCardExp] = Me.dteTWICCardExp.Value
rst![HireDate] = Me.HireDate.Value
rst![TermDate] = Me.TermDate.Value
rst.Update
Else
'Autofill form based on ID number entered
Me.txtSocSecNo.Value = rst![SocSecNo]
Me.txtCraft.Value = rst![Craft]
Me.txtJobNo.Value = rst![JobNo]
Me.txtLastName.Value = rst![LastName]
Me.txtSuffix.Value = rst![Suffix]
Me.txtFirstName.Value = rst![FirstName]
Me.txtMiddleInitial.Value = rst![MiddleInitial]
Me.txtTWICCardNo.Value = rst![TWICCardNo]
Me.dteTWICCardExp.Value = rst![TWICCardExp]
End If
End Sub
Any help I can get will be very much appreciated...Thanks!
CyndeQ