Title: Error: A RunSQL action requires an argument consisting of an SQL statement (2)

Posted on 2006-04-06
Last Modified: 2012-06-27
I couldn't figure out how to add an answer to a question, so I thought I'd send this as a question and let one of the "experts" append the answer to the original (original has same title...w/out the "(2)" at the end).

Question was from: Holddigga
Accepted Answer was from: heer2351

heer2351 recommends using a DLookup.  I found a way to use SQL SELECT statment with DAO.Recordset as follows:

    Dim rs As DAO.Recordset
    Dim sSQL As String

    sSQL = "SELECT Pack_Size_Code " & _
             "FROM Pack_Sizes " & _
             "WHERE Pack_Sizes.Size = "’ & PackSize & ‘"
    Set rs = CurrentDb.OpenRecordset(sSQL, dbOpenSnapshot)
    If rs.AbsolutePosition > -1 Then
        client = rs!PC_Code
    PC_Code = ""
    End If
    Set rs = Nothing
Question by:dstone8214
    1 Comment
    LVL 65

    Accepted Solution

                "WHERE Pack_Sizes.Size = "’ & PackSize & ‘"

    should be

                 "WHERE Pack_Sizes.Size = '" & PackSize & "'"

    I switched the single and double quote marks for you.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Introduction If you are not already aware of what you could use a table with sequential integer values for in SQL, you can read Delimited String Parsing in SQL Server 2005 or later ( by BrandonGalderisi (h…
    In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now