a dynamic query needing a sum function
- From: Philip_collins@xxxxxxxxxxx
- Date: Wed, 29 Aug 2007 11:11:10 -0700
Hi!
I have a dynamic query that has a form attached. I want to add up a
field with the sum funtion, the field is netkg.
Dim rec As Recordset
Dim qdf As QueryDef
Dim strsql
Set db = CurrentDb
db.QueryDefs.Refresh
For Each qdf In db.QueryDefs
If qdf.Name = "qryWeightsTotals" Then
db.QueryDefs.Delete qdf.Name
End If
Next qdf
strsql = "SELECT [Date],[Time],[makemodel],pao, Street,
[town],[Postcode],[gross weight],tare,[NetKG] FROM tblVanDetails WHERE
[RegistrationNo] = '" & zz & "'"
Set qdf = db.CreateQueryDef("qryWeightsTotals", strsql)
db.QueryDefs.Refresh
Me.Refresh
DoCmd.OpenForm "frmweightstotals", acNormal
Set db = Nothing
I have tried replacing [NetKG] with SUM([NetKG]) and SUM([NetKG]) as
TotalNet, this is with TotalNet dimmed as a variant. Have also
attempted, somewhat in ignorance, using the GROUP BY clause after the
where, however this results in a syntax error i.e. does not compile.
The first 2 result in an erroneous error message referring to
aggregating a date (netkg is not a date field), this may mean
something to others more enlghtened than I?!
any pointers would be much appreciated.
Regards
Phil
.
- Follow-Ups:
- Re: a dynamic query needing a sum function
- From: OldPro
- Re: a dynamic query needing a sum function
- Prev by Date: Re: Performing a SELECT INTO an external database
- Next by Date: Re: a dynamic query needing a sum function
- Previous by thread: Performing a SELECT INTO an external database
- Next by thread: Re: a dynamic query needing a sum function
- Index(es):
Relevant Pages
|
|