Solved

SQL insert syntax

Posted on 2010-09-14
3
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

749 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