Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-03-2019, 12:02 PM   #1
ypma
Newly Registered User
 
Join Date: Apr 2012
Location: Southamton England
Posts: 556
Thanks: 43
Thanked 79 Times in 79 Posts
ypma is on a distinguished road
Adding result of list box to Text box

Please point me in the right direction .
i have the results of four separate list boxes in four separate text boxes, No problem. I Now wish to add or sum of the four totals into one text box .

i have tried the following in the control source of the text box :
# =Nz([List341].Column(0))+Nz([List346].Column(0))+Nz([List929].Column(0))+Nz([List931].Column(0))#
and receive and invalid syntax error

Am i going about this the wrong way ?

Regards Ypma

ypma is offline   Reply With Quote
Old 12-03-2019, 12:10 PM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Adding result of list box to Text box

Hi. Did you actually have the hashtags in your expression? If so, maybe that's why you were getting a syntax error.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 12-03-2019, 12:11 PM   #3
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 2,112
Thanks: 20
Thanked 400 Times in 393 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Adding result of list box to Text box

Rather than reference[List341], try Me.List341.

Mark_ is offline   Reply With Quote
Old 12-03-2019, 12:17 PM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Adding result of list box to Text box

Quote:
Originally Posted by Mark_ View Post
Rather than reference[List341], try Me.List341.
That would probably produce an error in the Control Source of a Textbox. I think...
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 12-03-2019, 12:30 PM   #5
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 2,112
Thanks: 20
Thanked 400 Times in 393 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Adding result of list box to Text box

Give ?Name, but not a big issue. Was thinking in code.

What WILL happen, is if you don't tell NZ what to return you don't get what you expect. You also have to be careful since text boxes are treated as strings, so you wind up concatenating if your not careful.
Mark_ is offline   Reply With Quote
Old 12-03-2019, 12:54 PM   #6
ypma
Newly Registered User
 
Join Date: Apr 2012
Location: Southamton England
Posts: 556
Thanks: 43
Thanked 79 Times in 79 Posts
ypma is on a distinguished road
Re: Adding result of list box to Text box

Thank you for your response. 1 TheDbguy the Hashtag are not part of the control source ,referencing the control source with me.listbox was not accepted.
Mark, i think you have a point , as the result I receive from my effort is indeed concatenating, So how i can i avoid that. The results of the list boxes are Currency. I added the NZ as two of the fields were null, in the case i am working on. Your further advise would be appreciated

Regards Ypma
ypma is offline   Reply With Quote
Old 12-03-2019, 01:34 PM   #7
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 2,112
Thanks: 20
Thanked 400 Times in 393 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Adding result of list box to Text box

I would try using EVAL after concatenating your NZ's and your additions signs to make a proper string. Should look like the below;

Code:
=EVAL(Nz([List341].Column(0),0) & "+" & Nz([List346].Column(0),0) & "+" & Nz([List929].Column(0),0) & "+" & Nz([List931].Column(0),0))
I'd also rename your Lists to be more user friendly. List341 conveys little information while ListAmountIPay makes much more sense.

Mark_ is offline   Reply With Quote
The Following User Says Thank You to Mark_ For This Useful Post:
ypma (12-03-2019)
Old 12-03-2019, 02:40 PM   #8
ypma
Newly Registered User
 
Join Date: Apr 2012
Location: Southamton England
Posts: 556
Thanks: 43
Thanked 79 Times in 79 Posts
ypma is on a distinguished road
Re: Adding result of list box to Text box

Mark_ Thank you very much, your solution worked without the EVAL without any problems ,putting inverted commas around the + sign and the extra zero after the column.(0),0) did the trick.
Regards Ypma
ypma is offline   Reply With Quote
Old 12-03-2019, 02:58 PM   #9
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 2,112
Thanks: 20
Thanked 400 Times in 393 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Adding result of list box to Text box

Your very welcome!
Mark_ is offline   Reply With Quote
Old 12-03-2019, 03:04 PM   #10
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Adding result of list box to Text box

Quote:
Originally Posted by ypma View Post
Mark_ Thank you very much, your solution worked without the EVAL without any problems ,putting inverted commas around the + sign and the extra zero after the column.(0),0) did the trick.
Regards Ypma
Hi. Glad to hear you got it sorted out. Good luck with your project.

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum() adding 1 to the overall result? peskywinnets General 3 03-26-2015 01:38 PM
[SOLVED] Adding a Query result to a report HIMANSHU Reports 3 09-17-2013 01:30 AM
adding a count to the result of a query depending on the month raised monplankton General 4 08-19-2013 04:03 AM
2 list result query! tonycl69 Queries 5 11-20-2012 08:05 AM
Adding data from a drop down list without editing the list Sialia Forms 6 02-13-2012 11:29 AM




All times are GMT -8. The time now is 05:31 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World