Short version.
I have form that opens a linked form where data is populated automatically based on queries, and some data is entered. When this form closed I have SQL code that writes the various fields into the database, and then closes the form. The original for then recalcs so that the entered data now populated. Works grand...sometim es. Sometimes when you close the form, the data just doesn't write into the database due to a key violation (there's a field in the table that autopopulates so that each record has a unique ID). So you open the form again, re-enter your fields, and then it works. I can't figure out why it doesn't write every time.
Tell me what else I need to provide to help.
Update: Added Code
I have form that opens a linked form where data is populated automatically based on queries, and some data is entered. When this form closed I have SQL code that writes the various fields into the database, and then closes the form. The original for then recalcs so that the entered data now populated. Works grand...sometim es. Sometimes when you close the form, the data just doesn't write into the database due to a key violation (there's a field in the table that autopopulates so that each record has a unique ID). So you open the form again, re-enter your fields, and then it works. I can't figure out why it doesn't write every time.
Tell me what else I need to provide to help.
Update: Added Code
Code:
Dim strSQL As String
strSQL = "INSERT INTO tblMPR_Price([MPR_ID],[SKU]," & _
"[DeadOld],[DeadNew],[MAPOld],[MAPNew],[InvOld],[InvNew],[Rate],[Cost]) " & _
"VALUES (" & Me.[MPR_ID] & ",'" & Me.[SKU] & _
"','" & Me.[DeadOld] & "','" & Me.[DeadNew] & "','" & Me.[MAPOld] & _
"','" & Me.[MAPNew] & "','" & Me.[InvOld] & "','" & Me.[InvNew] & _
"','" & Me.[Rate] & "','" & Me.[Cost] & "');"
DoCmd.RunSQL strSQL
Comment