Results 1 to 2 of 2
  1. #1
    usselite is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    5

    Form SQL insert into

    Hello,

    At the moment I am building forms. I could write away the forms data away with a conventional way. But I would like to use an SQL query for it. Now I am aware of it that VBA is required to do this. But every time the SQL query seems to be placed in the VBA. I am wondering if its possible to make an reference to an query which is saved in access it self (so the SQL query is not hard-coded).



    Example:
    Not this:
    Dim strSQL As String
    strSQL = "... THE SQL STATEMENT GOES HERE ...”
    DoCmd.RunSQL strSQL

    But like this (somehow):
    strSQL = "query1"





  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,652
    Try

    DoCmd.OpenQuery "query1"

    You can also use

    CurrentDb.Execute "query1"

    but it will stumble over form references.
    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. INSERT multiple records from form
    By thart21 in forum Forms
    Replies: 5
    Last Post: 02-28-2013, 08:35 AM
  3. How do I insert an attachment using a form?
    By mitcheljp in forum Access
    Replies: 1
    Last Post: 06-18-2010, 08:53 AM
  4. Insert an image in a form
    By bladu in forum Forms
    Replies: 1
    Last Post: 09-10-2009, 11:13 AM
  5. Replies: 6
    Last Post: 08-17-2009, 01:41 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