View Single Post
  #1 (permalink)  
Old June 12th, 2003, 03:59 AM
jscully jscully is offline
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using DoCmd.RunSQL to return values

Greetings

Hopefully this is the right forum for this question.
I am developing an application with an Access frontend and MSSQL backend. The problem is that in my VBA code, I need to return values from tables such as the count of some records, or sum of some records etc.

To return values quickly, I know I can use stored procedures. I also know that I can run SQL on the backend using "DoCmd.RunSQL(sql_goes_here)". Finally, I know that I can use recordsets for extracting data. My question is:
Is it possible to use the "DoCmd.RunSQL(sql_goes_here)" command, but return the result to a variable? This would save lots of time.
e.g.
Dim intResult as integer
intResult = DoCmd.RunSQL("SELECT COUNT(*) FROM tblProducts")

Cheers

Joe