Results 1 to 6 of 6
  1. #1
    moises is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    15

    insert into query not populating the desired table

    I have coded my save button with the vba editor in my access.



    Currentdb.execute "insert into tbldata (field1, field2)values(" & me.value1 "," & me.value2 "');"

    The code has no error but it's not populating the table.

    Could anyone help me with the code?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'd use a variable so I could check the finished SQL:

    BaldyWeb-Immediate window

    Also, you can add a comma and dbFailOnError after your SQL or variable and you'll probably get your error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    There are syntax errors in the SQL (extra single-quote and missing &):

    Currentdb.execute "insert into tbldata (field1, field2)values(" & me.value1 &"," & me.value2 "');"

    Please post the real SQL you are using; if what you show is what you are using, then is the table REALLY named tbldata, and are the table fields REALLY named field1 and field2?

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by John_G View Post
    There are syntax errors in the SQL (extra single-quote and missing &):

    Currentdb.execute "insert into tbldata (field1, field2)values(" & me.value1 &"," & me.value2 "');"
    I'll get out of John's way, as I was going to try and teach you how to fish. That said, there's still a missing &.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    moises is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    15
    Mr. John_G attached is the database. I have an syntax error 3075.
    Attached Thumbnails Attached Thumbnails error.jpg  
    Attached Files Attached Files

  6. #6
    moises is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    15
    Thanks guys

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

Similar Threads

  1. Replies: 15
    Last Post: 02-16-2013, 08:10 AM
  2. Replies: 2
    Last Post: 03-11-2012, 07:35 AM
  3. Replies: 2
    Last Post: 12-20-2011, 07:33 AM
  4. Replies: 4
    Last Post: 10-03-2010, 09:54 PM
  5. Replies: 0
    Last Post: 02-24-2010, 12:56 AM

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