Share via

using the sum function

Anonymous
2018-06-10T22:53:12+00:00

I have a form with a text box in it and the control source in the properties is : =Sum([Profit/Loss]).

I need to add another column to it and from what I have been able to find it should look like this :  =Sum([Profit/Loss]+[txtcomm]) but this gives me an error message In the text box. What am I doing wrong?

both columns are currency and I am trying to add the total of both columns.

thank you

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

13 answers

Sort by: Most helpful
  1. Anonymous
    2018-06-11T03:28:29+00:00

    The main problem is that there are several reserved symbols in MS Access which cannot be used in field names- the "/" is one of them. See-

    https://support.office.com/en-us/article/learn-about-access-reserved-words-and-symbols-ae9d9ada-3255-4b12-91a9-f855bdd9c5a2

    Change the field name from [Profit/Loss] to [ProfitLoss].

    Al

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,830 Reputation points Volunteer Moderator
    2018-06-10T23:48:15+00:00

    The Sum() function is generally used to sum a value in multiple records. So I'm not sure if that's what you need. It will work if you only have a single record, however.

    If your form is a single record, then you should be able to use

    =[Profit/Loss]+[txtComm]

    That is assuming that txtComm is a control on your form. (Note txt is a prefix used for text box controls it does not necessarily indicate a text datatype).

    If the form is a continuous form, then this control should be in the form's footer And then I would use three controls:

    =Sum([Profit/Loss])

    =Sum([txtComm])

    =txtSumPL+txtSumComm

    It would help if you told us what the EXACT error message is. When asking for help you should always do that.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-06-10T23:25:11+00:00

    If [Profit/Loss] (hint: change the name, Tom's right!) is one field in the Recordset and [txtcomm] is another, and they both contain numeric values, you just need to move the parentheses:

    =Sum([Profit/Loss]) + [txtcomm]

    or perhaps

    =Sum([Profit/Loss]) + NZ([txtcomm])

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2018-06-10T23:16:25+00:00

    Based on its naming convention, txtcomm contains text. If so, you can't add it.

    Was this answer helpful?

    0 comments No comments
  5. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2018-06-10T23:09:57+00:00

    Use whatever is the ControlSource property of txtcomm.

    As an aside, field names should not contain funny characters like / or [space] - it can cause notational difficulties.

    Was this answer helpful?

    0 comments No comments