Solved

SQL insert syntax

Posted on 2010-09-14
3
299 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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