I would like to show the total (sum) of cost field in a Report. it should be simple but I am missing something.
I would like to show the total (sum) of cost field in a Report. it should be simple but I am missing something.
Expression in textbox in report footer: =Sum(fieldname)
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
when I created a Textbox in the footer of my report and entered "=Sum(Original Cost)" I received the message "The expression you entered contains invalid syntax."
No quotes.
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Also, due to the inadvisable space you'd need to bracket the field name:
=Sum([Original Cost])
I went back to my tools table and renamedtoCode:Original Cost.now I simply get #Error. also I tried assigning a name (TotCost) in front ofCode:Costthat gives Invalid Source code.Code:=sum(Cost)
Last edited by Aztecfan63; 08-05-2024 at 02:24 PM. Reason: miss spelling
You are leaving out the square brackets. That's how Access knows you are referring to a column in a table and not a custom function.
Put it back to Original Cost but as shown in post 5. Then from here on, no spaces or special characters in ANY object name. Underscore is allowed but I almost never use it in favour of Camel Case.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Brackets would be required around any object name that contains spaces, subject to naming rules AFAIK. That includes control names which Original Cost probably is, and would have to be an unbound control in order to contain an expression, hence it can't be a field name in this case.That's how Access knows you are referring to a column in a table
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
One of the reasons to rename the controls on your forms... so they have some kind of prefix... makes it obvious that it's a form control! =)
In my Tools table I went back to Original Cost. now in the Report textbox it looks like = Sum([Original Cost]). This causes: The expression you entered contains invalid syntax
Is [Original Cost] in the source that the report is based on?
Can you post the source? (if it's a table, is [Original Cost] a column in that table?)
1. yes, Original Cost is a field in my Tools Inventory table.
2. I did a Compact & Repair then Zip my database How do I send (post the source ) to you?
Click the Go Advanced button below the message text box and then you can upload your file.
Database7.zipThis is my Tools Inventory.