Query Syntax error

后端 未结 4 1675
渐次进展
渐次进展 2021-01-27 23:14

Please help me correct the following query:

SQL = \"insert into tblContract (Empid, Start1, Finish1, Store1, \" & _
                    \"Start2, Finish2, St         


        
4条回答
  •  一生所求
    2021-01-27 23:59

    Just remove VALUES:

    SQL =  "
           INSERT INTO tblContract (Empid, Start1, Finish1, Store1, Start2, Finish2, Store2)
           SELECT " & Me.txtEmpNo.Value & "', MAX(testid), '" &
           Me.txtContSunStart1.Value & "', '" & Me.txtContSunFinish1.Value & "','" & 
           Me.txtContSunStore1.Value & "','" & Me.txtContSunStart2.Value & "', '" & 
           Me.txtContSunFinish2.Value & "','" & Me.txtContSunStore2.Value & "' " &
           "FROM tbltesting'"
    

    Since you have 7 target fields and 8 SELECT list expressions, this won't compile until you provide an extra field in the INSERT clause where you want your MAX(testid) to go to.

提交回复
热议问题