Query /sql question

R

Reidar

I have a query that counts number of records with a certain Where-condition
like

SQL1 = _
"SELECT Count(tblUtleieLokal.UtleieID) AS AntallUtleieID " & _
"FROM tblUtleieLokal " & _
"WHERE tblUt.........

DoCmd.RunSQL SQL1

I need to get the value of AntallUtleieID into a variable.
How do I do that?

reidarT
 
A

Albert D.Kallal

Use

Just use the dsum function

myvariable = dsum("column to sum", "table to sum", "where conditions")

So, in your example, we have

myvariable = dsum("UtleieID","tblUtleieLokal"," where...")

note that you do NOT include the word "where" in the above sql condition
part....
 
Top