Hello World,
I have this code that copy values to table:
How to add/revise a/the code that if UserID, QAType, QuestionID, CorrectAnswer was already added in the target Table to save, it will only replace ChoiceAnswer and Checking not to add another record when execute.
Thank you so much in advance.
I have this code that copy values to table:
Code:
On Error GoTo ErrorHandler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb()
Set qdf = db.CreateQueryDef("", "INSERT INTO [TBL_Answer] (UserID, QAType, QuestionID, ChoiceAnswer, CorrectAnswer, Checking) VALUES ([MyVal1], [MyVal2], [MyVal3], [MyVal4], [MyVal5], [MyVal6])")
qdf.Parameters("[MyVal1]") = Forms![FRM_Question]![Text_StoredUser]
qdf.Parameters("[MyVal2]") = Forms![FRM_Question]![Text101]
qdf.Parameters("[MyVal3]") = Forms![FRM_Question]![Text_CurRecord]
qdf.Parameters("[MyVal4]") = Forms![FRM_Question]![Frame89]
qdf.Parameters("[MyVal5]") = Forms![FRM_Question]![Text_Answer]
qdf.Parameters("[MyVal6]") = Forms![FRM_Question]![Text_Check]
qdf.ReturnsRecords = False
qdf.Execute
ExitMe:
Set qdf = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description
GoTo ExitMe
How to add/revise a/the code that if UserID, QAType, QuestionID, CorrectAnswer was already added in the target Table to save, it will only replace ChoiceAnswer and Checking not to add another record when execute.
Thank you so much in advance.