Results 1 to 2 of 2
  1. #1
    tariq1 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    16

    Run-time error 2342

    Hi, within a form, clicking on a combobox I have the following code A) which is generating
    the run-time error B)
    Thank you in advance for your help on this


    A)
    Code:
    
    Private Sub Category_Click()
    
    Dim strSQL As String
      strSQL = "select customers.* from customers"
      DoCmd.RunSQL strSQL
    End Sub
    B)
    Run-time error ‘2342’:



    A RunSQL action requires an argument consisting of an SQL statement

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You typically do not run Select queries in RunSQL statements like that, as select queries don't perform any type of updateable action (like a Make Table, Append, or Delete query).
    What is it exactly that you are trying to do with this?
    Are you trying to open/view the query results? If so, then assign the SQL code to a query object, and open that query, i.e.
    Code:
    CurrentDb.QueryDefs("MyQuery").SQL=strSQL
    DoCmd.OpenQuery "MyQuery", acViewNormal, acEdit

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

Similar Threads

  1. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  2. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  3. Replies: 2
    Last Post: 12-23-2010, 09:11 AM
  4. Replies: 2
    Last Post: 12-02-2010, 02:35 AM
  5. Run Time Error 424
    By ddog171 in forum Programming
    Replies: 3
    Last Post: 02-04-2006, 07:13 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