J
Johnny C.
I'm looking for an easier, more elegant method...I have code in a form that
creates a temp query using sql, then using dlookup to get data, eg. using sql
to return a count of records that meet a specific criteria from a table, then
using dlookup to return the count. eg:
Dim qry As QueryDef
Set qry = New QueryDef
With qry
.Name = "tempqry"
.sql = "SELECT Count(LastName) as CountLastName, LastName " & _
"FROM Staff " & _
"GROUP BY LastName " & _
"WHERE LastName = 'Smith';"
End With
then later
dim x as integer
x = DLOOKUP("[CountLastName]","[tempqry]","[LastName] = 'Smith'")
Is there a more elegant way to pass the result from a sql statement straight
into a variable?
creates a temp query using sql, then using dlookup to get data, eg. using sql
to return a count of records that meet a specific criteria from a table, then
using dlookup to return the count. eg:
Dim qry As QueryDef
Set qry = New QueryDef
With qry
.Name = "tempqry"
.sql = "SELECT Count(LastName) as CountLastName, LastName " & _
"FROM Staff " & _
"GROUP BY LastName " & _
"WHERE LastName = 'Smith';"
End With
then later
dim x as integer
x = DLOOKUP("[CountLastName]","[tempqry]","[LastName] = 'Smith'")
Is there a more elegant way to pass the result from a sql statement straight
into a variable?