SQL INSERT Statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atrottier
    New Member
    • Jul 2007
    • 17

    SQL INSERT Statement

    Having a little trouble with an INSERT statement. I get a runtime error "Missing semicolon(;) at end of SQL statement". This is the INSERT statement:
    "INSERT INTO [ExtractDate] ( UniqueID, StartDate ) " & _
    "VALUES ( [Unique ID] , Actual_Start )" & _
    "FROM [AIS Release and Transport Status]" & _
    "WHERE Actual_Start <> 'NA' ; "
    Column "Unique ID" is of type number and "Actual_Sta rt is a text field from the "AIS Release and Transport Status" table and the columns being inserted into on the "ExtractDat e" table match the data types. Any help is greatly appreciated.
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    HI
    Originally posted by atrottier
    Having a little trouble with an INSERT statement. I get a runtime error "Missing semicolon(;) at end of SQL statement". This is the INSERT statement:
    "INSERT INTO [ExtractDate] ( UniqueID, StartDate ) " & _
    "VALUES ( [Unique ID] , Actual_Start )" & _
    "FROM [AIS Release and Transport Status]" & _
    "WHERE Actual_Start <> 'NA' ; "
    Column "Unique ID" is of type number and "Actual_Sta rt is a text field from the "AIS Release and Transport Status" table and the columns being inserted into on the "ExtractDat e" table match the data types. Any help is greatly appreciated.
    Perhaps this will do it
    "INSERT INTO [ExtractDate] ( UniqueID, StartDate ) " & _
    "SELECT [Unique ID] , Actual_Start " & _
    "FROM [AIS Release and Transport Status] " & _
    "WHERE Actual_Start <> 'NA' ; "

    ie. its not a value list but a list from a subquery ??

    Note additional space at end of lines 2 & 3


    MTB

    Comment

    • atrottier
      New Member
      • Jul 2007
      • 17

      #3
      MTB, Thanks for the response but that doesn't do it. This is a simple insert into a table I created to draw out dates from a table created to load data from a imported Excel file. This code is in the "Clicked" event of a command button. I guess I need to ask is it possible to insert into one table from another table using the actual column names as assigned in the "FROM TABLE". I've been able to figure out the "INSERT INTO" into using values assigned to variable names and actual values but I can't figure out the "INSERT INTO" syntax when inserting from another table. Once again thanks in advance for any responses.

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        Hi, the solution provided by MTB is an example of inserting from one table to another. He has used the correct syntax and it should work. The type of query is called an append query in Access. Perhaps you could elaborate as to why his solution did not work for you? What error did you receive?

        Comment

        • atrottier
          New Member
          • Jul 2007
          • 17

          #5
          Mike and JKing, I revisted what Mike posted and retyped it the way he had it and it does work. Once again my big fat fingers get in the way of each other on the keyboard. Thanks guys, you're certainly helping out this newbie.

          Comment

          Working...