Fireman1143
IS-IT--Management
I hve placed the following code on the OnClick button on a form. The SQL statement is to append the training records for a particular training session based on the employee name having a checkbox marked. When I tried the query it worked fine EXCEPT I had to manually type in the training session ID [tsPRIID]. I copied and transferred the code to notepad and have built the following code -
Dim strSQL As String
strSQL = ""
strSQL = strSQL & "INSERT INTO tblEmpTraining ( trEmpPRIID, trTrainDate, trGroup, trTopic, trHours ),"
strSQL = strSQL & "SELECT tblEmployees.EmpPRIID, tblTrainingSession.tsSessionDate, tblTrainingSession.tsGroup, tblTrainingSession.tsSessionTopic, tblTrainingSession.tsSessionHrs,"
strSQL = strSQL & "FROM tblEmployees, tblTrainingSession,"
strSQL = strSQL & "WHERE (((tblEmployees.AppendCkBox)<>0) AND ((tblTrainingSession.tsPRIID)= " & Me.txt_tsPRIID & "));"
DoCmd.RunSQL strSQL
Now I get the following error message -
Syntax error in INTO INSERT statement.
Dim strSQL As String
strSQL = ""
strSQL = strSQL & "INSERT INTO tblEmpTraining ( trEmpPRIID, trTrainDate, trGroup, trTopic, trHours ),"
strSQL = strSQL & "SELECT tblEmployees.EmpPRIID, tblTrainingSession.tsSessionDate, tblTrainingSession.tsGroup, tblTrainingSession.tsSessionTopic, tblTrainingSession.tsSessionHrs,"
strSQL = strSQL & "FROM tblEmployees, tblTrainingSession,"
strSQL = strSQL & "WHERE (((tblEmployees.AppendCkBox)<>0) AND ((tblTrainingSession.tsPRIID)= " & Me.txt_tsPRIID & "));"
DoCmd.RunSQL strSQL
Now I get the following error message -
Syntax error in INTO INSERT statement.