Results 1 to 4 of 4
  1. #1
    FRAZ is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    12

    using the SQL view in code

    How would I take the SQL statement generated by the query design, and place it directly in to code? I would like to get away from the "docmd.openquery" statement.
    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
    Copy/paste then edit as appropriate - enclose in quote marks, concatenate dynamic parameters, continuation character for multi-line code. Like:

    CurrentDb.Execute "UPDATE tablename SET fieldname = " & Me.textboxname & _
    " WHERE ID=" & Me.ID

    This pertains only to action SQL. SELECT query only for opening a recordset object.
    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.

  3. #3
    FRAZ is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    12
    Thank will give it a try

  4. #4
    oldslr is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    1
    If you google sql2vba it should show a link to allenbrowne.com. He has a form you can build, which can not only simplify the task, but will also show you the needed changes to go from Access SQL to vBA SQL layout.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2013, 11:30 AM
  2. Replies: 3
    Last Post: 07-20-2012, 11:41 AM
  3. How to access design view and VBA code
    By abrogard in forum Access
    Replies: 8
    Last Post: 03-22-2012, 05:47 PM
  4. Code to call Split Form View Datasheet
    By ahightower in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 04:57 PM
  5. Replies: 4
    Last Post: 01-11-2010, 11:41 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