Results 1 to 3 of 3
  1. #1
    magicscreen is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    2

    Duplicate Record Cannot Save

    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

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you append twice of the record somewhere, but I could not find where.

  3. #3
    magicscreen is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    2
    Thank you for your response.

    I determined the same thing but I too cannot see where this is happening.

    I also am not sure if I may accidentally be trying to update the Employee table which should only be used to fill the combobox dropdown list.

    This is driving me crazy.

    For some reason, when I requery the recordsource in the AfterUpdate event after selecting an employee from the combobox, the ProblemID does not show on the form and I get an error stating that a key field cannot contain blanks, If I set it manually after requerying the recordsource, I get the duplicate record error.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. If duplicate record, go to original record
    By BigBear in forum Forms
    Replies: 2
    Last Post: 10-06-2010, 02:58 AM
  2. Duplicate a Record
    By AKQTS in forum Forms
    Replies: 11
    Last Post: 08-09-2010, 05:25 PM
  3. If duplicate record, go to original record
    By islandboy in forum Access
    Replies: 51
    Last Post: 06-02-2010, 04:17 PM
  4. Delete record if duplicate
    By rubintheyid in forum Access
    Replies: 8
    Last Post: 03-30-2010, 11:33 AM
  5. Duplicate record failure
    By bugchaser in forum Access
    Replies: 5
    Last Post: 05-21-2009, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums