Question : Updating a table using SQL and variables

I need to update tblPAA with variables defined in the sub procedure.

DoCmd.RunSQL "INSERT INTO tblPPA (intPPAID, intIncidentID, txtPPAEffectiveDate, txtPPAPeriod, datPPAExpiryDate, txtFirstName, txtMiddleName, txtLastName, txtAddress, txtCity, txtStateProv, txtPostalZip, txtDOB, txtDatedDate, txtInvestigator, intViolationSelfExclusion) SELECT (strPPANum, intIncidentID, datPPAEffectiveDate, strPPAPeriod, datPPAExpiryDate, strFirstName, strMiddleName, strLastName, txtAddress, txtCity, txtStateProv, txtPostalZip, datDOB, datDate, strInvestigator, strViolationSE);"

When I run this line of code I get: "syntax error (comma) in query expression"

Answer : Updating a table using SQL and variables

try this


DoCmd.RunSQL "INSERT INTO tblPPA (intPPAID, intIncidentID, txtPPAEffectiveDate, txtPPAPeriod, datPPAExpiryDate, txtFirstName, txtMiddleName, txtLastName, txtAddress, txtCity, txtStateProv, txtPostalZip, txtDOB, txtDatedDate, txtInvestigator, intViolationSelfExclusion) Values ('" & strPPANum & "',"& intIncidentID &", #"& datPPAEffectiveDate &"#,'" & strPPAPeriod & "', #"& datPPAExpiryDate &"#, '" & strFirstName & "', '" & strMiddleName & "', '" & strLastName & "', '" & txtAddress & "', '" & txtCity & "', '" & txtStateProv & "', '" & txtPostalZip & "', #"& datDOB &"#, #"& datDate &"#, '" & strInvestigator & "', '" & strViolationSE & "');"
Random Solutions  
 
programming4us programming4us