SQL Error

  • Thread starter Thread starter JonWayn
  • Start date Start date
J

JonWayn

Set rst1 = db.OpenRecordset("SELECT Counties, " _
& "DSum([CountA],[RecordCounts],[Dataset] = 'Total') AS [TotalIn] "
_
& "FROM RecordCounts " _
& "GROUP BY Counties " _
& "ORDER BY Counties;")


I keep getting the message "you tried to execute a query that doesnt include
the specified expression 'DSum([CountA],[RecordCounts],[Dataset] = 'Total')'
as part of an aggregate function

What do I need to do to this SQL to make it work?

Thanks a lot.
 
Concatenate the value returned by DSum() into your SQL string:

"SELECT Counties, " & _
DSum("[CountA]", "[RecordCounts]", "[Dataset] = 'Total'") & _
" AS [TotalIn] FROM ...
 
Back
Top