Posted on 2003-02-18
Medium Priority
Last Modified: 2010-11-11
I have a form in MS Access 2000. In the form I have a combo box that passes the variables to a SQL statement I want to execute:
Dim SQL As String
    SQL = "SELECT dbo_string.StringID, dbo_string.StringCode, dbo_string.NeutralValue, dbo_stringlocalized.LocalizedValue "
    SQL = SQL & "FROM dbo_string INNER JOIN dbo_stringlocalized ON dbo_string.StringCode = dbo_stringlocalized.StringCode "
    SQL = SQL & "WHERE (((dbo_string.stringcode) = [dbo_stringlocalized].[stringcode]) And ((dbo_string.ActiveFlag) = 1) "
    SQL = SQL & "And ((dbo_string.LocalizeFlag) = 1) And ((dbo_stringlocalized.ActiveFlag) = 1)) "
    SQL = SQL & "AND ((dbo_stringlocalized.LocaleLanguageCountryIdentifier)= " & Combo0.Value & ")"

The last line gives me an error: "A RunSQL action requires an argument consisting of an SQL statement."

I just want to output the results to the screen.

Question by:ebtech
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 41

Accepted Solution

shanesuebsahakarn earned 200 total points
ID: 7978964
RunSQL needs an action query (ie an INSERT, APPEND or DELETE sql satement) rather than a SELECT statement.

To output the query to screen, try this:
First of all, create a query (it doesn't matter what the query does) and save it, call it something like qryTemp.

Next, instead of the RunSQL line, try this:
CurrentDb.QueryDefs("qryTemp").SQL = SQL
DoCmd.OpenQuery "qryTemp"

You'll need a reference to DAO - open a code module, click Tools->References and make sure Microsoft DAO 3.6 is checked. That should do what you need.

Author Comment

ID: 7978990
This works great, thanks

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Suggested Courses

765 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