I've posted the code I'm using behind a cmd_save_click() event where based on whether I'm adding a record or just updating one my function either appends or updates a record accordingly. I am getting some weird (funky) errors when I test however. I'll list them below here, what I would like to know is if these are b/c of my code or somthing else I've done wrong.
this record has been changed by another user since you started editing it. If you save the record you will overwrite the other changes made. ..
with save record, add to clipboard and drop changes as the buttons at the bottom" - this is what happens when I am attempting to update a record after I have done an update once in my form already
"Runtime Error 3022
The changes you have requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the field or fields that contain duplicate data, remove the index or redefine the index to allow duplicates" this one occurs when I first try and append a new record to my table.
The weirdest part is that even WITH the records, nine times out of ten the record does get written to the table anyway....
Let me know what you think!
Private Sub cmd_save_Click()
If Me.AllowAdditions = True Then
CurrentDb.Execute "INSERT INTO Players_t ( JerseyNumber, PlayerName, Weight, PositionF ) VALUES (" & _
Forms!frm_playerinfo!txt_JerseyNumber & ", '" & Forms!frm_playerinfo!txt_PlayerName & "', " & _
Forms!frm_playerinfo!txt_Weight & ", '" & Forms!frm_playerinfo!cbo_PositionF & "')"
CurrentDb.Execute "UPDATE Players_t SET JerseyNumber = " & Forms!frm_playerinfo!txt_JerseyNumber & " , PlayerName = '" & _
Forms!frm_playerinfo!txt_PlayerName & "', Weight = " & Forms!frm_playerinfo!txt_Weight & ", PositionF = '" & _
Forms!frm_playerinfo!cbo_PositionF & "' WHERE JerseyNumber = " & Forms!frm_playerinfo!txt_JerseyNumber & " "
Me.Dirty = False