Solved

SQL insert syntax

Posted on 2010-09-14
3
253 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:deanlee17
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33669819
you won't use VALUES when you do a SELECT:


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

Open in new window

0
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 33669830
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???
0
 

Author Comment

by:deanlee17
ID: 33669848
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.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now