I have a form that has two subforms on it in datasheet view. One shows the training an employee should have based on there job assigment and the other form shows what they actually have. I have the subform that shows what they should have with an on click event that adds the training type to the current selected employee. The current event is:
Private Sub Training_Name_Click()
Dim trainmsg As Integer
trainmsg = MsgBox("Are you sure you want to add this training type to the selected employee?", 1, "Training Addition Message")
If trainmsg = 1 Then
DoCmd.SetWarnings warningsOff
DoCmd.OpenQuery "Query_Append_missingtraining"
DoCmd.SetWarnings warningsOn
MsgBox "A new record has been added.", vbInformation + vbOKOnly, "Record Added"
Forms![Spot_Missing_Training]![What_Employee_does_Have].Requery
End If
End Sub
Is there away I can set this up so that it looks first to see if the employee has the training type that is selected and if not, that it runs the append query and if does a message pops up saying that the a record exists and ends the event?
I thought of running the below querry and setting the event to occur depending on if the result is null or equal to but I don't know how to code that.
SELECT Training_Completed.Training_ID, Training_Completed.Employee_ID, Training_Completed.Training_Type
FROM Training_Completed
WHERE (((Training_Completed.Employee_ID)=[Forms]![Spot_Unassigned_Training]![employee_id]) AND ((Training_Completed.Training_Type)=[forms]![spot_Unassigned_Training]![What Employee Should Have]![id]));
Private Sub Training_Name_Click()
Dim trainmsg As Integer
trainmsg = MsgBox("Are you sure you want to add this training type to the selected employee?", 1, "Training Addition Message")
If trainmsg = 1 Then
DoCmd.SetWarnings warningsOff
DoCmd.OpenQuery "Query_Append_missingtraining"
DoCmd.SetWarnings warningsOn
MsgBox "A new record has been added.", vbInformation + vbOKOnly, "Record Added"
Forms![Spot_Missing_Training]![What_Employee_does_Have].Requery
End If
End Sub
Is there away I can set this up so that it looks first to see if the employee has the training type that is selected and if not, that it runs the append query and if does a message pops up saying that the a record exists and ends the event?
I thought of running the below querry and setting the event to occur depending on if the result is null or equal to but I don't know how to code that.
SELECT Training_Completed.Training_ID, Training_Completed.Employee_ID, Training_Completed.Training_Type
FROM Training_Completed
WHERE (((Training_Completed.Employee_ID)=[Forms]![Spot_Unassigned_Training]![employee_id]) AND ((Training_Completed.Training_Type)=[forms]![spot_Unassigned_Training]![What Employee Should Have]![id]));