Solved

Dsum problem

Posted on 2000-04-27
8
625 Views
Last Modified: 2012-06-27
I'm creating a membership database and have problem about Dsum function. Well, i'm in the client form, but wanna know how much each client's paid so far. When i looked at the Sample Db from MSAccess ( Named Membership), i can use Dsum to get the sum from another table. This is the code from the sample
"=IIf(IsNull([MemberID]),0,DSum("[PaymentAmount]","Payments","[MemberID]=" & [MemberID]))"

So, i copied the code and paste it to my form, and changed from the [MemberID] to be [CaseID]. I also have "Payment" table, and "paymentAmount" field, The relationship is one to many. Unfortunately, i got the #error. Do u have any idea?

 
0
Comment
Question by:TerryOh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 6

Expert Comment

by:bknouse
ID: 2755831
Try changing the name attribute of the control on the form (you find this in the properties OTHER tab).  If you originally had this named, Access gets confused and displays the #error instead of the value.

Brent
0
 
LVL 1

Expert Comment

by:JCE
ID: 2755851
If MemberId is a integer then I think your code should be like this.
=IIf(IsNull([MemberID]),0,DSum("[PaymentAmount]","Payments","[MemberID]=" & [MemberID] & ""))

If MemberId is text then it should be like this.
=IIf(IsNull([MemberID]),0,DSum("[PaymentAmount]","Payments","[MemberID]='" & [MemberID] & "'"))
Good luck
JCE
0
 

Author Comment

by:TerryOh
ID: 2756091
JCE, My MemberID is Texe, but when I tried the code that u told me, i got Blank field instead of #error. Why?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 10

Expert Comment

by:paasky
ID: 2756399
Hello TerryOh,

You should add quotes or double quotes to criteria if you're comparing string (text) type fields:

=IIf(IsNull([MemberID]),0,DSum("[PaymentAmount]","Payments","[MemberID]='" & [MemberID] & "'"))

or

=IIf(IsNull([MemberID]),0,DSum("[PaymentAmount]","Payments","[MemberID]=" & Chr(34) & [MemberID] & Chr(34)))

chr(34) = "

Hope this helps,
Paasky

0
 
LVL 1

Accepted Solution

by:
JCE earned 20 total points
ID: 2756414
Try this first
=DSum("[PaymentAmount]","Payments","[MemberID]='" & [MemberID] & "'")
and next
=DSum("[PaymentAmount]","Payments","[MemberID]='abc'")
abc is your MemberID.
Let me know if it works.
JCE

0
 
LVL 10

Expert Comment

by:paasky
ID: 2756418
Oh oh! Sorry JCE, my intention was not to step on your toes.

Paasky
0
 
LVL 10

Expert Comment

by:paasky
ID: 2756467
Hmm.. I think the Iif is not necessary needed here, try this instead:

=DSum("[PaymentAmount]","Payments","[MemberID]='" & NZ([MemberID],"####") & "'")

Paasky



0
 

Author Comment

by:TerryOh
ID: 2756927
Hey, JCE, it works!!!!!

Thank you!!

JCE, paasky, and bknouse
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question