Adding two or more value
I am trying to get two values from a database to add up to a new value on my label. I tried to run it through VB script command but the returned value always came back blank. Here is what I came up with.
I have the Data type set to Number. When I switch it to Text it seems to work but it presents me with the two values not added together. Just wondering how I would get this to work.
Ultimately I would like to be able to add up multiple fields from a database that will then equal one sum on a label. Thanks!
-
Peter Thane
★ BarTender Hero ★
Add the code to the OnNewRecord section rather than on AutoSelected and maybe add a default value here like Value = 99
I am guessing the fields are concatenating rather than summing together and to do this you need to add a CInt command to each variable and so you end line would be
Value = CInt(Value1) + CInt(Value2)
0 -
Rafael Seward
★ BarTender Hero ★
So I added the command "value = "99" to the OnAutoSelectedEvent section and added the commands you recommended to the OnNewRecord section.
Unfortunately I am still running into an issue. I am getting this error after I did the CInt command-
OnNewRecord (Line 5): Overflow: 'CInt'
Also, I am trying to get the sum of these two values (1+1=2) so not sure it that involves another type of command or this current one. Thank you for the help thus far though!
0 -
Peter Thane
★ BarTender Hero ★
Both the fields you are adding need to be numeric only fields and so if they have an mg suffix in the data this will not work. If this is the case you will need to add them on a a numeric only field on the label template but to the side of the label so they do not print, name the data sources and then instead of linking Value1 and Value2 to the database fields link them to the named data sources instead.
This is what I get
0
Please sign in to leave a comment.
Comments
3 comments