ms access - INSERT INTO code returns a Compiler Error: Expected: End of Statement -
i wrote simple code insert record in test data table. followed msdn example cannot past compile error. have tried recordset , table name alone. same error.
private sub cmdcommitchg_click() 'this tester environment dim ztemp1, ztemp2, ztemp3 string 'these dummy data append table dim tblinsert string dim dbsdonors dao.database dim rcdtemptester dao.recordset set rcdtemptester = dbsdonors.openrecordset("tbltemptester") ztemp1 = "tempid" ztemp2 = "tempentity" ztemp3 = "tempname" insert rcdtemptester!tbltemptester (id_members, id_entity, member_name) values (ztemp1, ztemp2, ztemp3) end sub
you mixing vba , sql. this:
private sub cmdcommitchg_click() 'this tester environment dim ztemp1 string dim ztemp2 string dim ztemp3 string dim tblinsert string dim dbsdonors dao.database dim rcdtemptester dao.recordset ztemp1 = "tempid" ztemp2 = "tempentity" ztemp3 = "tempname" set rcdtemptester = dbsdonors.openrecordset("tbltemptester") rcdtemptester.addnew rcdtemptester(ztemp1).value = <some id> rcdtemptester(ztemp2).value = <some entity> rcdtemptester(ztemp3).value = <some name> rcdtemptester.update rcdtemptester.close set rcdtemptester = nothing set dbsdonors = nothing end sub
Comments
Post a Comment