Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum / DSum error

Status
Not open for further replies.

jmob

Programmer
Jun 21, 2005
58
US
My error is somewhere in the DSum syntax.
I am trying to sum the columns on a subform, and put that sum value into the parent form field.I am getting an error that says it can't find the field "|" referred to in my expression. I tried using the regular Sum(..) , but I was getting some kinda of aggregate error. thanks.

sqlCmd = "Update [TableA] Set [TableA].[hours]= " & DSum([TableB].hours, [TableB], [TableB].id= Me.id)
& " where " & Me.id & " = [TableA].id
 
Something like this ?
sqlCmd = "Update [TableA] Set hours=DSum('hours', '[TableB]', 'id=" & Me.id & "') where id=" & Me.id

Another way:
sqlCmd = "UPDATE tableA SET hours=(SELECT Sum(hours) FROM tableB WHERE id=tableA.id) WHERE id=" & Me.id

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top