Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with SQL statement.

Status
Not open for further replies.

tbiceps

IS-IT--Management
Nov 23, 2005
106
US
When I run the following SQL statement in the immediate window. I get the following error:
The SELECT statement includes a reserved word or an argument name that is mispelled or missing, or the punctuation is incorrect.

DoCmd.RunSQL " Select TESTTABLE t, TBL_FieldID f, TBL_Index i WHERE t.[Report ID]=i.[Report ID] AND f.[Field ID] = i.[Field ID]
 
How about this statement. I get a run-time error '2342'
A RunSQL action requires an argument consisting of an SQL statement.

Code:
DoCmd.RunSQL "SELECT t.[Report ID], f.[Full Field Name] FROM TESTTABLE t, TBL_FieldID f, TBL_Index i WHERE t.[Report ID]=i.[Report ID] AND f.[Field ID] = i.[Field ID]"
 
tbiceps

Create your queries in design view, switch to SQL view and grab that. It 's ready for use and error free.......[thumbsup2]
 
The SQL is OK but RunSQL is designed to process Action or Data Definition queries.

This "Select" query is not one of those.
 
RunSQL expects an action query. Your query is a select query.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks Golom and JerryKlmns, as usual, I try to overthink the problem.
 
Is there a way to test a select query in vba or is design view/SQL view the way to go.
 
You can of course use VBA and open a recordset but the Query designer is probably the mechanism of choice for testing SQL statements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top