Re: DSUM syntax problem
From: connieharper (anonymous_at_discussions.microsoft.com)
Date: 03/28/04
- Next message: SteveS: "Re: DSUM syntax problem"
- Previous message: Steve Schapel: "Re: Huge database weighs heavily on small brain"
- In reply to: fredg: "Re: DSUM syntax problem"
- Next in thread: SteveS: "Re: DSUM syntax problem"
- Reply: SteveS: "Re: DSUM syntax problem"
- Reply: fredg: "Re: DSUM syntax problem"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 28 Mar 2004 10:53:48 -0800
Thanks for your reply. I tried your example but the field
just shows #NAME.
You asked some questions.
comparing student_id and employee_id is correct
In the tbl_accounting table, the charge field is text, the
student_id field is a number. employee_id is a number
field on the form.
I want to get a total of all records in the
tbl_accounting table that have a student_id that matches
the employee_id on the form and that have the
word "Charge" for the type.
Is this statement still correct to do that?
=DSum("[amount]","Tbl_accounting","[type] = '" & Me!
[charge] & "' And [student_id] = " & Me![employeeid])
Thanks.
>-----Original Message-----
>On Sun, 28 Mar 2004 07:45:20 -0800, connieharper wrote:
>
>> I have a form that contains a calculated field. I want
it
>> to display a total for all records in the
tbl_accounting
>> table for the employee that is displayed on the form
and
>> for the type displayed on the form. I have used the
>> following dsum statement in the controlsource property
of
>> this field:
>>
>> =DSum("[amount]","Tbl_accounting","[type] =[charge]"
>> And "[student_id] = [employeeid]")
>>
>> It comes back with a grand total of all the records in
the
>> table and doesn't limit the selection based on the TYPE
or
>> the EMPLOYEE.
>>
>> If I remove the AND part of the statement, it works.
It
>> comes back with a total of all the records in the table
>> that have a TYPE = to the TYPE on the form. But I want
to
>> also limit the selection of records to the employee who
is
>> displayed on the form. I guess my syntax is wrong.
Anyone
>> know what is wrong with it?
>>
>> Thanks
>
>Your syntax, for one thing, is incorrect.
>The AND is outside the quotes. I must be inside the
quotes.
>
>Also, you have [Student_ID] = [EmployeeID]. Is that
correct (Student
>field = Employee field)?
>Also, the exact placement of quotes (and whether to use
Single or
>Double quotes) is dependent upon the datatype of the
criteria fields.
>So... what is the datatype of [Type] and what is the
datatype of
>[StudentID]? What is [Charge]? Is that a field on your
form, or is
>that supposed to be "Charge" (text)? Same thing with
[EmployeeID]. Is
>that a control on the form? Is it a number?
>
>Let's say that [Type] is Text Datatype, and [StudentID]
is Number and
>[Charge] and [EmployeeID] are control names on your form.
>Use:
>=DSum("[amount]","Tbl_accounting","[type] = '" & Me!
[charge] & "'
> And [student_id] = " & Me![employeeid])
>
>Access will process the where clause similar to this:
>=DSum("[amount]","Tbl_accounting","[Type] = 'SomeType' AND
>[Student_id] = 185")
>--
>Fred
>Please only reply to this newsgroup.
>I do not reply to personal email.
>.
>
- Next message: SteveS: "Re: DSUM syntax problem"
- Previous message: Steve Schapel: "Re: Huge database weighs heavily on small brain"
- In reply to: fredg: "Re: DSUM syntax problem"
- Next in thread: SteveS: "Re: DSUM syntax problem"
- Reply: SteveS: "Re: DSUM syntax problem"
- Reply: fredg: "Re: DSUM syntax problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|