DSum Object Required in Access

201 views Asked by At

I have a subform in Access 2010 that lists the costs associated with different parts of a project. On another page, I have a TotalValue field that takes the sum of the costs for each project, and multiplies it by 1,000,000. Originally, I had just Parent.[TotalValue] = Me.Est_Value.Value * 1000000, but that didn't sum the costs. So I tried adding a DSum, but it's giving be a runtime error 424: Object Required at the DSum line.

Private Sub Est_Value_AfterUpdate()

Me.Recalc
Parent.[TotalValue] = DSum(Projects.EstValue, 
       Projects, Projects.ProjNo = Activity.ProjNo) * 1000000
Parent.[UpdatedCosts] = Date
Parent![Updated Costs].Requery
Parent!Text263.Requery

End Sub 

I'm not really sure what's wrong with it, so I would appreciate any help.

1

There are 1 answers

7
Newd On BEST ANSWER

I don't really have any working examples of this. But based off of what I am reading here: http://www.techonthenet.com/access/functions/domain/dsum.php

It should look more like this:

Me.Parent.[TotalValue] = DSum("EstValue", "Projects", "Projects.ProjNo = " & Activity.ProjNo) * 1000000

This is assuming Activity.ProjNo is a form property and that Projects.ProjNo is an numeric field.

Update: From further discussion the Activity.ProjNo was not the control that contained the ProjNo value and it was MFProjectsSubform.ProjNo instead. So the code should look like:

Me.Parent.[TotalValue] = DSum("EstValue", "Projects", "Projects.ProjNo = " & MFProjectsSubform.ProjNo) * 1000000