Getting the SUM of a fiel from an unrelated table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two tables:
- Students (contains student info, field 'tuition_payed' and 'course')
- Course (contains info about each course)

The two tables have a relationship. Every student can be in only one course.

My form uses Course as a recordSet. I have a textBox control that will
contain the SUM of tuition payed by all students taking the course of the
current record. So I would like to the textBox filled with the value from the
following query:

SELECT SUM(tuition_payed) FROM Students WHERE course=myform![course_num];

What is the best way to do this?

thanks
 
I have two tables:
- Students (contains student info, field 'tuition_payed' and 'course')
- Course (contains info about each course)

The two tables have a relationship. Every student can be in only one course.

My form uses Course as a recordSet. I have a textBox control that will
contain the SUM of tuition payed by all students taking the course of the
current record. So I would like to the textBox filled with the value from the
following query:

SELECT SUM(tuition_payed) FROM Students WHERE course=myform![course_num];

What is the best way to do this?

Probably

=DSum("[Tuition_payed]", "[Students]", "[Course] = " & [Course_Num])


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top