Results 1 to 2 of 2
  1. #1
    DBDave is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    6

    RunSQL INSERT INTO VALUES

    This works fine to insert avalue from a form text box into a table field:



    DoCmd.RunSQL "INSERT INTO myTable(stringField1) Values ( [Forms]![myForm]!myControl)"

    Now I want to also INSERT two additional fields, so:

    DoCmd.RunSQL "INSERT INTO myTable(stringField1, smallIntField, stringField2 ) Values ( [Forms]![myForm]!myControl), x, y"

    Where x is number 1
    y is a string constant "Yes"

    Can you help me out with the syntax for the x and y values? The delimeters confound me every time. Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I use CurrentDb.Execute to avoid the popup warnings.

    CurrentDb.Execute "INSERT INTO myTable(stringField1, smallIntField, stringField2 ) Values ('" & [Forms]![myForm]!myControl) & "', 1, 'Yes')"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Subform INSERT INTO...VALUES Problem
    By dipitiduda2 in forum Programming
    Replies: 1
    Last Post: 04-14-2014, 09:55 AM
  2. Replies: 1
    Last Post: 03-17-2014, 02:13 AM
  3. Custom Message Box for verifing RunSQL Insert
    By robsworld78 in forum Programming
    Replies: 8
    Last Post: 05-01-2013, 09:33 AM
  4. Replies: 1
    Last Post: 05-25-2012, 02:29 AM
  5. How do I Insert Values w/ Not Exists sub select?
    By toddbailey in forum Queries
    Replies: 1
    Last Post: 05-01-2012, 12:05 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