When a user enters the required data and clicks on the ’Save’ button, I would like to copy the record and paste it into the same table with one exception in that the Date Completed is placed into the PrevTrgCompDate field.
I have the following code which works great except that the Date Completed data is not placed into the PrevTrgCompDate field. (Last line of the code).
Can someone point out to me where I am going wrong and the best way to fix this issue.
Code:
Private Sub btnSave_Click()
If IsNull(Me.Date_Completed) Then
MsgBox "Date Completed is required"
Me.Date_Completed.SetFocus
Else
If IsNull(Me.Trained_By) Then
MsgBox "Trained By is required"
Me.[Trained_By].SetFocus
Else
Me.Required.Value = False
Dim currentID As Long
currentID = TrainingID
DoCmd.GoToRecord record:=acNewRec
EmployeeID = DLookup("EmployeeID", "tblTrainingHistory", "TrainingID=" & currentID)
TrainingItemID = DLookup("TrainingItemID", "tblTrainingHistory", "TrainingID=" & currentID)
TrainingCodeSOPNo = DLookup("TrainingCodeSOPNo", "tblTrainingHistory", "TrainingID=" & currentID)
TrainingDescription = DLookup("TrainingDescription", "tblTrainingHistory", "TrainingID=" & currentID)
IssueNo = DLookup("IssueNo", "tblTrainingHistory", "TrainingID=" & currentID)
PrevTrgCompDate = DLookup("Date_Completed", "tblTrainingHistory", "TrainingID=" & currentID)