Results 1 to 6 of 6
  1. #1
    Kirtap is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    22

    Whats wrong with my query

    Hello,
    I had a question. Is there anything wrong with this query?

    INSERT INTO Assets(Asset_ID, GPCL_Asset_ID, Asset_Type, Manufacturer, Model, Serial_Number, Description) VALUES(213,'E674',38,171,'37250-00','006631','E674 37250-00 006631 EMC Lab B28'),(214,'E253',255,285,'37250-00','006663','E253 37250-00 006663 EMC Lab');

    I have it stored in a variable called Asset_SQL.

    The values without single quotes are integer datatypes

    In VBA, I am trying to insert to insert multiple values in one query into a table in a database. Unfortunately, when I try to execute it, I get a message stating Run-time error '3137': Missing semicolon (; )at end of SQL Statement.

    I tried DoCmd.RunSQL Asset_SQL and I also tried CurrentDb.Execute Asset_SQL

    I apologize if this is the wrong section, but I figured maybe something was wrong with my query maybe?



    Someone said get rid of the VALUES part, but that just gave me a message saying my INSERT was wrong.

    Thank you in advance,
    Kirtap

  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,641
    Quote Originally Posted by Kirtap View Post
    Hello,
    I had a question. Is there anything wrong with this query?
    Yes, with a VALUES clause you can only insert a single record.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Kirtap is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    22
    Thanks!

    How can I make it so it enters multiple records in one statement? Or is this not possible?

    Edit: Somehow the sql statement got truncated when I copied it. My apologies this is what the sql statement originally looked like.
    INSERT INTO Assets(Asset_ID, [GPCL_Asset_ID], [Asset_Type], [Manufacturer], [Model], [Serial_Number], [Description]) VALUES(213,'E674',43,170,'37250-00','006631','E674 37250-00 006631 EMC Lab B28'),(214,'E253',255,285,'37250-00','006663','E253 37250-00 006663 EMC Lab');
    Last edited by Kirtap; 10-01-2013 at 10:07 AM. Reason: Changed multiple values to multiple records.; fixing grammar

  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,641
    From a table, sure:

    INSERT INTO...
    SELECT...
    FROM...
    WHERE...

    If you're in VBA, you should be able to run the SQL twice, each with a different set of values.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Kirtap is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    22
    I see. So I do need to run more than one sql statement.
    Anyhow, thanks! I guess consider this solved.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problemo.
    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. Query creating records *2 of whats in database
    By brow1726 in forum Queries
    Replies: 3
    Last Post: 12-12-2012, 06:58 PM
  2. Replies: 1
    Last Post: 05-17-2012, 02:41 PM
  3. Replies: 4
    Last Post: 04-23-2012, 11:46 PM
  4. Whats wrong with this code?
    By shabbaranks in forum Programming
    Replies: 2
    Last Post: 03-20-2012, 08:01 AM
  5. Replies: 6
    Last Post: 09-01-2010, 03:12 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