SQL Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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???
 
RunSQL is used to run an action query, not a select query. Your query is a
select query.

Try
DoCmd.OpenQuery strSQL
 
Back
Top