Bartender VBA Help: Calculations based on form entry data
I would love some help with doing VBA calculations based on data input from a form. Currently, I have it only semi-working but only when data is manually inputted from Bartender rather than after print is initiated from PrintStation and the form requests data. Note: Bartender 2016
The scenario is this: we frequently have to send Topboards (“TBs”) and Layerboards (“LBs”) back to a supplier. It is often, at least once a week, and the number of TBs and LBs can vary significantly. When shipped they require a label with counts of LBs and TBs and weights. This is currently done manually, and I wish to automate this somewhat with Bartender.
This is what I have made so far:
Label setup. Note some data sits outside of the label intentionally.
The form.
My named sources:
Named Source | Description |
---|---|
TBcount_ | From a form: number of TBs |
TBx_ | Weight of individual TB, manually input and unchanging |
TBw_ | Total weight of all TBs (TBcount_ * TBx_) |
LBcount_ | From a form: number of LBs |
LBx_ | Weight of individual LB, manually input and unchanging |
LBw_ | Total weight of all LBs (LBcount_ * LBx_) |
PALw_ | Weight of a pallet, manually input and unchanging |
TOTALweight_ | Total weight of TBs, LBs, and Pallet (TBw_ + LBw + PALw_ = TOTALweight_) |
How it works is that you input the count for each, it multiplies this by the individual weight, and then add these together with the weight of the pallet.
In essence:
TBcount_ * TBx_ = TBw_
LBcount_ * LBx_ = LBw_
TBw_ + LBw + PALw_ = TOTALweight_
My code for TOTALweight_:
Value1 = format.NamedSubStrings("TBw_").Value * 1
Value2 = format.NamedSubStrings("LBw_").Value * 1
Value3 = format.NamedSubStrings("PALw_").Value * 1
Value = (Value1 + Value2 + Value3)
I can’t get this to work when I print and fill out the form – the calculations only take place if I do it manually. Is anyone able to give some pointers? Thanks!!!
-
Peter Thane
★ BarTender Hero ★
Have you tried setting the Total Weight field as a VB Script>Event Controlled>OnPostPrompt or OnIdenticalCopies field to force the VB to be processed after all the data has been entered?
0
Please sign in to leave a comment.
Comments
1 comment