Link to home
Start Free TrialLog in
Avatar of deanlee17
deanlee17

asked on

SQL insert syntax

Hi Experts,

Im trying to add the following code to the after update command of a dropdown menu.

DoCmd.RunSQL "INSERT INTO PSNForFilter([PSN]) VALUES([Student reference]) FROM UNITE_MIS_ENROL WHERE [Class reference] = '" & Me.[course_dropdown] & "'"

The run-time error I get is 3137 missing semicolon (;) at end of SQL statement. If i put the semicolon in there then it gives a compile error?

Many Thanks,
Dean
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DoCmd.RunSQL  "INSERT INTO PSNForFilter([PSN]) VALUES([Student reference]) FROM UNITE_MIS_ENROL WHERE [Class reference] = '" & Me.[course_dropdown] & "' ;"

is this giving you compile error???
Avatar of deanlee17
deanlee17

ASKER

Thanks very much Angel, that worked perfectly.
Santos: I didnt try your solution because angelll suggested VALUES was not required. But thank you for taking the time to reply.