Re: DSUM syntax problem
From: fredg (fgutkind_at_example.invalid)
Date: 03/28/04
- Next message: Steve Schapel: "Re: Huge database weighs heavily on small brain"
- Previous message: Fred Worthington: "Re: Huge database weighs heavily on small brain"
- In reply to: connieharper: "DSUM syntax problem"
- Next in thread: connieharper: "Re: DSUM syntax problem"
- Reply: connieharper: "Re: DSUM syntax problem"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 28 Mar 2004 18:13:48 GMT
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: Steve Schapel: "Re: Huge database weighs heavily on small brain"
- Previous message: Fred Worthington: "Re: Huge database weighs heavily on small brain"
- In reply to: connieharper: "DSUM syntax problem"
- Next in thread: connieharper: "Re: DSUM syntax problem"
- Reply: connieharper: "Re: DSUM syntax problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|