I am using windows 7 64 bit 8 gigs of memory Access 2007
I am developing a tracking system
I have a main form and can have one or more employees woring on the problem
I created a continuous subform using a table named EmployeeAssinment.
One of the fields is a combobox.
When I try to save a record, I receive a message stating that the record could not be saved because it would create a duplicate.
However, when I close the form "without savibg" the record, the record is actually saved in the EmployeeAssignment table.
Primary Key: ProblemID. EmpID
The fields on the form are: EmpID, ProblemID, FirstName, LastName FullName (ComboBox) and HoursWorked.
The combobox is filled from the Employee table.
Is there any way I can find out what table is having the duplication problem?
I tried to set up a recordset to save the assignment information and then set the RecordSource of the form to give me all EmployeeAssignment records for the current problem.
When I received the error, I commented out the recordsource but still get the same error.
I get the ProblemID from the main parent form.
After saving the recordset, I need to set the EmpID on the form or it doesn't get set and I wind up with a "Key Field Cannot Be Blank" error.
This is my sub:
Private Sub cmbEmployee_AfterUpdate()
On Error GoTo Err_cmbEmployee_AfterUpdate
intProbID = Me.Parent.ProblemID
Set dbAssignment = CurrentDb
Set rsAssignment = dbAssignment.OpenRecordset("Select * From tblEmployeeAssignment", dbOpenDynaset)
rsAssignment.FindFirst "EmpID='" & cmbEmployee.Column(0) & "' and ProblemID=" & intProbID
If rsAssignment.NoMatch Then
rsAssignment.AddNew
rsAssignment!EmpID = Me!cmbEmployee.Column(0)
rsAssignment!ProblemID = intProbID
Else
rsAssignment.Edit
End If
rsAssignment!EmpLastName = Me!cmbEmployee.Column(1)
rsAssignment!EmpFirstName = Me!cmbEmployee.Column(2)
rsAssignment!EmpFullName = Me!cmbEmployee.Column(3)
rsAssignment!Hours = Me.Hours
txtEmpID = rsAssignment!EmpID
' Me.intProblemID = intProbID
' Me.EmpID = Me!cmbEmployee.Column(0)
rsAssignment.Update
rsAssignment.Close
DoEvents
Me.RecordSource = "Select * From tblEmployeeAssignment Where ProblemID=" & intProbID
Exit Sub
Err_cmbEmployee_AfterUpdate:
If Err.Number = 3058 Then
Exit Sub
End If
MsgBox Err.Number & " " & Err.Description
Exit Sub
Resume Next
End Sub