Results 1 to 15 of 15
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Total of unbound text fields

    I have 5 unbound text fields, the user enters a money amount there. I want the total of these 5 fields to be in the "Total" field, but sometimes the user only uses only 2 of the 5 unbound text fields for example. I have tried it like this:
    Code:
    =[Summe1]+[Summe2]+[Summe3]+[Summe4]+[Summe5]
    but it only works if all 5 fields have a value, so how can I solve this differently?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,431
    use the nz function

    =nz([Summe1],0)+nz([Summe2],0)+......

  3. #3
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    use the nz function

    =nz([Summe1],0)+nz([Summe2],0)+......
    I did it like this:
    =nz([Summe1],0)+nz([Summe2],0)+nz([Summe3],0)+nz([Summe4],0)+nz([Summe5],0)
    but there is always an error:
    The expression you entered is syntactically incorrect

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,431
    don't see anything wrong with the syntax - You do have this in the controlsource of an unbound text box? And all the control names are correct?

  5. #5
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Yes i do have the control names correct and i have it in the controlsource

    If it helps this is the full error message:
    You have not specified an operand or operator, you have entered an invalid pointer or comma, or you have entered text without enclosing it in inverted commas.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    I want the total of these 5 fields to be in the "Total" field
    If that means you want to store the total in a table field, then you should forget about solving this and should not store the total.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,431
    OK so you are saying you can't enter the formula, you get an error when you try to exit the controlsource.

    So start with entering

    =[Summe1]

    in the control source then move to a different property. If that works then modify to
    =nz([Summe1],0)

    and if that works, add the next

    =nz([Summe1],0)+[Summe2]

    etc

  8. #8
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Micron View Post
    If that means you want to store the total in a table field, then you should forget about solving this and should not store the total.
    I don't want to save it in a table but I want it to be visible in the report.

  9. #9
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    OK so you are saying you can't enter the formula, you get an error when you try to exit the controlsource.

    So start with entering

    =[Summe1]

    in the control source then move to a different property. If that works then modify to
    =nz([Summe1],0)

    and if that works, add the next

    =nz([Summe1],0)+[Summe2]

    etc
    =[Summe1] this works.

    =nz([Summe1],0) but this doesnt work

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Any chance you can post a copy of your db? As long as all the field names are correct, what you've been trying should work.
    Note - you would copy db, compact/repair the copy and zip. See how to attach files at top of forum window if you need it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Micron View Post
    Any chance you can post a copy of your db? As long as all the field names are correct, what you've been trying should work.
    Note - you would copy db, compact/repair the copy and zip. See how to attach files at top of forum window if you need it.
    Database1.zip
    This is an prototype of the DB.

  12. #12
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,431
    works for me

    Click image for larger version. 

Name:	image_2022-11-16_170750802.png 
Views:	15 
Size:	12.0 KB 
ID:	49124

  13. #13
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by CJ_London View Post
    works for me

    Click image for larger version. 

Name:	image_2022-11-16_170750802.png 
Views:	15 
Size:	12.0 KB 
ID:	49124
    What exactly did you put in the controlsource? Or could you please post your variation from the db?

  14. #14
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,431
    I put as advised

    =nz([Summe1],0)+nz([Summe2],0)+nz([Summe3],0)+nz([Summe4],0)+nz([Summe5],0)

    just copy/paste the above

    if the nz doesn't work for you, perhaps it is a language thing

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Me too. I didn't worry about the nz yet though.

    Click image for larger version. 

Name:	Akchayan.jpg 
Views:	11 
Size:	34.4 KB 
ID:	49125

    but nz works too

    Click image for larger version. 

Name:	Akchayan2.jpg 
Views:	11 
Size:	36.0 KB 
ID:	49126
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 01-07-2019, 01:51 AM
  2. Replies: 1
    Last Post: 04-26-2016, 01:13 AM
  3. Unbound text box equals two conjoined fields
    By brharrii in forum Reports
    Replies: 1
    Last Post: 10-23-2012, 04:26 PM
  4. Replies: 4
    Last Post: 08-14-2012, 10:33 AM
  5. Replies: 1
    Last Post: 08-13-2010, 01:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums