473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

DSum Syntax Woes

I have a field on a form that I'm trying to show the total of the invoices that have come in for the project. The ProjectID is field on the form which is in the forms primary table (ContractInfo). There is a child table called "Invoices" which is also has a ProjectID field that ties those records to the ContractInfo table, and of course it has a field for the InvoiceAmt. So in this ContractInfo form I have a text box and I'm using the following syntax to try and show the invoice total for the contract. So I use this statement, which I swear has worked for me many times before, but it doesn't work now - the text box shows "#error".

=DSum("[InvoiceAmt]","Invoices","[ProjectID] = " & [ProjectID])

If I knock off the where clause it works, but of course it's grabbing all of the invoices in the table - but it shows that it's the where clause that the trouble lies. I've checked and triple checked that the control on the form is called "ProjectID" and that the field in the "Invoices" table is called "ProjectID", so what doesn't it like? Below is the syntax right from the Microsoft Help site.

DSum("[Quantity]*[UnitPrice]", "Order Details", "[ProductID] = " & [ProductID])

Does anyone know what might be wrong? If not, is there a better way to accomplish this?
Thanks.
Feb 5 '08 #1
3 2588
ADezii
8,834 Expert 8TB
I have a field on a form that I'm trying to show the total of the invoices that have come in for the project. The ProjectID is field on the form which is in the forms primary table (ContractInfo). There is a child table called "Invoices" which is also has a ProjectID field that ties those records to the ContractInfo table, and of course it has a field for the InvoiceAmt. So in this ContractInfo form I have a text box and I'm using the following syntax to try and show the invoice total for the contract. So I use this statement, which I swear has worked for me many times before, but it doesn't work now - the text box shows "#error".

=DSum("[InvoiceAmt]","Invoices","[ProjectID] = " & [ProjectID])

If I knock off the where clause it works, but of course it's grabbing all of the invoices in the table - but it shows that it's the where clause that the trouble lies. I've checked and triple checked that the control on the form is called "ProjectID" and that the field in the "Invoices" table is called "ProjectID", so what doesn't it like? Below is the syntax right from the Microsoft Help site.

DSum("[Quantity]*[UnitPrice]", "Order Details", "[ProductID] = " & [ProductID])

Does anyone know what might be wrong? If not, is there a better way to accomplish this?
Thanks.
The only thing that comes to mind is that if the [ProjectID] Filed was Text instead of Numeric, the syntax would be:
Expand|Select|Wrap|Line Numbers
  1. =DSum("[InvoiceAmt]","Invoices","[ProjectID] = '" & [ProjectID] & "'")
Other than that I can't think of anything else since you already verified other info that could concievably cause the problem. If you like, you can send me the DB as an E-Mail Attachment and I would be happy to have a look at it.
Feb 6 '08 #2
The only thing that comes to mind is that if the [ProjectID] Filed was Text instead of Numeric, the syntax would be:
Expand|Select|Wrap|Line Numbers
  1. =DSum("[InvoiceAmt]","Invoices","[ProjectID] = '" & [ProjectID] & "'")
Other than that I can't think of anything else since you already verified other info that could concievably cause the problem. If you like, you can send me the DB as an E-Mail Attachment and I would be happy to have a look at it.
You were exactly correct. I must have never used this method before with a text field. Thanks!
Feb 6 '08 #3
ADezii
8,834 Expert 8TB
You were exactly correct. I must have never used this method before with a text field. Thanks!
Glad it worked for you.
Feb 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rolan | last post by:
I'm using Access 97 and need some assistance in sorting out a proper DSum expression, or maybe even DCount might be an alternative. I have tried numerous combinations, but with no apparent success....
2
by: Dalan | last post by:
I seemed to be having problems with structuring the use of NZ with a DSum expression. Having tried numerous variations of the expression without success, I'm asking for assistance. First some...
3
by: Mark Reed | last post by:
All, I have never used this function before and am not sure it what I need. Just to clarify, I have a report based on a query which has amoungst other field, wk, parea & packs_req. What I am...
0
by: seanseaghan | last post by:
New to this group, so greetings all! I am trying to develop query syntax in Access 2000 to accomplish the following: Imagine you are in an accounting dept. and you are working on a...
1
by: Marc Aube | last post by:
Is there a web site that can ofer some help. The quotation marks are posing an issue as well as other items for this function. I have some books but they are not consistent in their use of the code...
1
by: gbb0330 | last post by:
Hi All i am trying to calculate Quantity on hand in a unbound textbox in a form with a subform QonHand=Qreceived - TotalQSold TotalQsold=QsoldOnEbay+QsoldThruOtherChannels here is my...
6
by: Mike | last post by:
Dim vDateE As String vDateE = #7/12/2005# The following works to find Cost in TblExpenses for 7/12/2005: MsgBox (DSum("Cost", "TblExpenses", "DateofPurchase = #7/12/2005#")) However I...
1
by: kaosyeti | last post by:
so i'm new to access but i've done a lot in the last 3 months since i looked at it for the first time back then. so when i finished my first db for my job, i cut it close to the end of the year...
33
by: potassium flower | last post by:
I am trying to create a food order system for a restaurant. I have tried using both the DSum and Sum functions to calculate the total cost of an order. The total cost is a textbox on the form...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.