select statement into a variable

vijay

Registered User.
Local time
Today, 17:49
Joined
Apr 28, 2003
Messages
16
Hi All,
on a "Run Report" button of a form,i have the following code:
Dim strsql
strSQL = "SELECT sum(shutdowns) FROM System1"

when i debug and try to read the "strSQL" value,it always shows strSQL holding the string "SELECT sum(shutdowns) FROM System1" instead of the sum.

could anyone please point as to what I am doing wrong?

Thanks
 
Use DSum

Hi:)

StrSql is just a variable which will just hold the sql query as text. Try using DSUm to store value in a variable so instead of writting

strSQL = "SELECT sum(shutdowns) FROM System1"

write

strSQL=DSum("Shutdowns","System1")
msgbox (StrSQL)

You can also use Dlookup like

strSQL=Dlookup("Sum(shutdowns)","System1")

that should do the trick....good luck

Cheers!
Aqif
 
Thanks aqif,
I figured as much.
Thanks for the new idea.Ill try it later.
 

Users who are viewing this thread

Back
Top Bottom