Results 1 to 4 of 4
  1. #1
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169

    Insert INTO syntax help

    Hi,
    Can somebody help me out with the syntax with this? I am trying to run an insert into sql command on a form. I was able to get the following code to run correctly. QuestID is a Number value.
    Code:
    DoCmd.RunSQL "INSERT INTO tblQuestions ( Question, QuestionCode )SELECT tblQuestionsLinked.Question, tblQuestionsLinked.QuestionCode FROM tblQuestionsLinked WHERE tblQuestionsLinked.QuestID = " & Me.QuestID
    When I try to run the following similar code with QuestionCode as the WHERE parameter (which is a text value) I am getting a popup window that says "Enter Parameter Value" with the Me.QuestionCode value showing in the window and a blank field. If I type the Me.QuestionCode Value into the blank field it then appends the data to the table. I assume I need to adjust this second set of code somewhat to account for the fact that Me.QuestionCode is a text value. Can somebody help me out with the syntax on this second code? Thanks.
    Code:
    DoCmd.RunSQL "INSERT INTO tblQuestions ( Question, QuestionCode )SELECT tblQuestionsLinked.Question, tblQuestionsLinked.QuestionCode FROM tblQuestionsLinked WHERE tblQuestionsLinked.QuestionCode = " & Me.QuestionCode


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For a text value:

    "...WHERE tblQuestionsLinked.QuestionCode = '" & Me.QuestionCode & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Thanks Paul....that did the trick!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help Jim.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  2. Combine insert into syntax
    By Cojack in forum Queries
    Replies: 1
    Last Post: 09-22-2010, 07:48 AM
  3. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  4. SQL INSERT INTO Date Syntax Error
    By tuna in forum Programming
    Replies: 5
    Last Post: 08-10-2010, 06:17 AM
  5. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums