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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How: Criteria on a DSUM Function 1

Status
Not open for further replies.

Ogart

Technical User
Mar 26, 2003
104
US

Here’s what I’m trying to do. I have a table full of items called T_Equipment. Sometimes, an item will be a combination of several items in T_Equipment (e.g. a motor + a base plate + some screws, etc). I have a table called T_MakeUps that has this information.

T_Equipment has (among other things) a field called “ModelNumber”
T_MakeUp has only two fields: “ParentNumber” and “ItemsWithinParent”. The data in both fields come from T_Equipment.

The idea is that I have all items in one lovely table. A legacy system at a previous gig had different lists for stand alone items, and for these “make ups” and it was a royal mess.

I’ve build a form for T_Equipment, and a subform for T_MakeUps. All is well.

What I’m trying to do next is add up all the Suggested List Prices and Costs…kind of important. I’ve turned to my trusty DSUM Function, and I’m stuck as to the criteria statement at the end.

Dim F As Form
Set F = Me
Dim TempList As Single
TempList = DSum("E_ListPrice", "T_Equipment", "??")

In English, my criteria is:
Sum up the E_ListPrices of all the items in T_Equipment where the item appears in T_MakeUp in the “ItemsWithinParent” field and the item in “ParentNumber” Matches the particular record I’m working with in this form. (And that particular record is F!ModelNumber).
 
Create a query linking the T_Equipment and T_Makeup tables and use that in your DSUM. Assuming your query brings in the records correctly then your criteria becomes:

TempList = DSum("E_ListPrice", "YourQueryName", _
"ParentNumber = " & F!ModelNumber)

Note: If the above are strings then it becomes:

TempList = DSum("E_ListPrice", "YourQueryName", _
"ParentNumber = '" & F!ModelNumber & "'")

Good LucK!

 
Duh. Should have thought of that. Star for you and thanks for the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top