RunSQL is only for Action queries (INSERT INTO, UPDATE, SELECT ... INTO or
DELETE)
You would have to create a query and run the query:
Dim qdfTemp As DAO.QueryDef
Set qdfTemp = CurrentDb.CreateQueryDef("qryTemp", vSql)
DoCmd.OpenQuery "qryTemp"
Note that qryTemp cannot already exist in this case. If this is something
you're going to do repeatedly, you're best off creating a "permanent" query
object, and just resetting its SQL property as required:
Dim qdfTemp As DAO.QueryDef
Set qdfTemp = CurrentDb.QueryDefs("qryTemp")
qdfTemp.SQL = vSQL
DoCmd.OpenQuery "qryTemp"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Mark" <(E-Mail Removed)> wrote in message
news:AB19E00B-0D2A-4209-AEB7-(E-Mail Removed)...
> Hello all,
>
> How can I display the results of SQL in VB. Here is the SQL and it will
> have multiple records.
>
> vSql = "select count(*), area_id from wcs_to_via_t " & _
> "where trans_stt = '00' " & _
> "and dtimecre Between #" & vSDate & "# and #" & vEDate & "#" & _
> "group by area_id " & _
> "Order by area_id, count(*)"
>
> DoCmd.RunSQL (vSql)