2 records added to table after form is submitted

funwithaccess

Registered User.
Local time
Today, 01:09
Joined
Sep 5, 2013
Messages
80
Hi,

I have a form that has a few combo boxes that I use as drop down lists that the user can choose from. After the form is completed, the user clicks "Submit" and the query/table is updated. However, 2 records are added instead of 1. The first record leaves the first field blank and every other field completed. The second record has every field filled out with the same info as the first. In other words, the first of the 2 records is unnecessary. How do I eliminate this from happening?

Data Entry set to "Yes"

Submit button:
Code:
Private Sub cmdSubmit_Click()
    
    DoCmd.RunSQL "Insert Into qryEarlyPoints(empName,dateOfOccurrence,leaveEarly,early6Mins) VALUES('" & Me.txtEmpNameInf & "','" & Me.txtDateInf & "','" & Me.cmbEarlyPoints & "','" & Me.cmbArriveEarly & "')"
    Application.SetOption "Confirm Action Queries", 0
    Application.SetOption "Confirm Document Deletions", 0
    Application.SetOption "Confirm Record Changes", 0

    DoCmd.Close
    
cmdSubmit_Click_Exit:
    Exit Sub

End Sub

Thank you for your assistance!
Nate
 
If I had to guess, the form is bound to the table. You want code or bound form, not both.
 
You nailed it! I set the form to be unbound and deleted the control source for each combobox and the text boxes.

Thank you for your help!
 

Users who are viewing this thread

Back
Top Bottom