SQL Error

S

Steve S

The follpwing code in an event procedure produces the error:
A RunSQL action requires an argument consisting of an SQL statement:

Dim strSQL As String

strSQL = "SELECT Penalties.Type,Penalties.Penalty FROM Penalties;"
MsgBox strSQL
DoCmd.RunSQL strSQL

the messabe box displays what seems to be a valid sql string. It look like:

SELECT Penalties.Type,Penalties.Penalty FROM Penalties;

when I cut the text between the " marks and paste it in a query it works
just fine and display the expected results.

what am I missing here???
 
K

Ken Snell \(MVP\)

RunSQL is used to run an action query, not a select query. Your query is a
select query.

Try
DoCmd.OpenQuery strSQL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top