DroplistBox: Cumulative total based on one quantity column and one code material column

9 posts / 0 new
Last post
Paolo_S
Offline
Joined: 09/07/2016 - 06:13
DroplistBox: Cumulative total based on one quantity column and one code material column

Hi Brian

I've written a few larger scripts, they working as they should. Now I want to make them more user friendly by using dropdown.

I used some of the script found on the forum.

This scrip should calculate the cumulative quantity for each material code. In the drolistbox we selected the material code field and the quantity field:

Field amount will be used after the cumulative quantity.

The script creates the field CUMULATIVE_TOTAL but not calculate the cumulative quantity and returns this error:



I attach the code.

Could you help me?

Many thanks.

 

Files: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Paolo,

I will have a look and get back to you.

Brian

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Paolo,

The problem is with this field:

Set field = table.GetField(GIACENZA_PROGR)

but you haven't defined what GIACENZA_PROGR is.  Should it not be equal to one of the fieldnames selected from the dialog?

Brian

Paolo_S
Offline
Joined: 09/07/2016 - 06:13

Hi Brian,
The field GIACENZA_PROGR is create with the function Create Field. I modified the script and i removed the functions "checkIfFieldNameExists". The error remain but the script create the field "GIACENZA_PROGR" but all the records are equal to 0.
I attach the new script version.
I'll be waiting for your advices.
Many thanks.
Paolo.

Files: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Paolo,

Is GIACENZA_PROGR actually a name of the field?  If so you need it in quotes becuase on that line you are referencing a variable that contains nothing, if you want to use that field then you have two options.

1. is to add the fieldname to the variable such as: GIACENZA_PROGR = "GIACENZA_PROGR" and have this line after the Dim statements in the function or change the Set field = table.GetField(GIACENZA_PROGR) to Set field = table.GetField("GIACENZA_PROGR") so the function will look for that field name instead of what is contained within the variable.

Hope that helps out.

Brian

Paolo_S
Offline
Joined: 09/07/2016 - 06:13

Hi Brian,
Thanks for your attention, I apologize for the many messagges.
I modified the script but there is the same error on line 69 where i wrote ULTIMO_ARTICOLO_LETTO = "". When I initialize variables.I don't have idea where is the problem.
Many thanks.Paolo

Files: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Paolo,

I was just able to run your script.  I made two changes, one was to line 57 which is eqn = "0.00000", I needed to change the comma to a period but that is most likely because of my regional settings, probably not a problem for you.  The other was on line 71 QTA= 0.00000 you had it within double quotes but as this is a double variable it should not be within quotes.  I changed the comma to a period as I believe that items outside of the equation editor need to follow the English rules but I could be wrong, so you can try it with both a period or a comma. Here is what I got when I ran it on the Sample - Detailed Sales and selected these fields.

 

 

 

Paolo_S
Offline
Joined: 09/07/2016 - 06:13

Hi Brian,
Thank you very much, now everithing works.
Your help has been really appreciated.
Paolo.
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

That is great to hear!!