dlookup and sql
From: Johnny C. (JohnnyC_at_discussions.microsoft.com)
Date: 08/21/04
- Next message: Dale Fye: "Re: Stup-id question about Count query"
- Previous message: Brian: "Re: Global Variable as query parameter"
- Next in thread: John Spencer (MVP): "Re: dlookup and sql"
- Reply: John Spencer (MVP): "Re: dlookup and sql"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 21 Aug 2004 07:21:01 -0700
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?
- Next message: Dale Fye: "Re: Stup-id question about Count query"
- Previous message: Brian: "Re: Global Variable as query parameter"
- Next in thread: John Spencer (MVP): "Re: dlookup and sql"
- Reply: John Spencer (MVP): "Re: dlookup and sql"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|