Number of Print Copies from VB Script Calculation S’abonner

Timothy Ott

I'm looking to determine the # of print copies from a VB Script.  Essentially, we are looking to divide data from a data source (DBSource.DBField) by a form input (FormInputField) value.  There are also times where the quotient will have a decimal and we need to round it up (no matter what the decimal is).  This is what I have come up with so far:


Value = Round(((Int(Field("DBSource.DBField")))/(Int(Format.Objects("FormInputField").Type))),0)


It continues to error out due to:  OnAutoSelectedEvent(Line 1): : Type mismatch: '[string: ""]'


I can't figure out how to get this to work, and would appreciate any help on it.

2 commentaires

Peter Thane

This is how I would do it:

  1. Add a field on the Template page but to the right of the label so that it is there but will not be printed. This assumes that the value you are entering from your Format.Objects("FormatInputField") value does not appear on the label itself, if it does just place it on the field as normal
  2. Go into the Properties of this field and in the Data Source screen click the Change Data Source Name and give the field a name, such InputNumber
  3. As with 2 above, for ease I would give the DBSource field a name too (such as DBNumber)
  4. On the Data Entry Form add on a Text or Number input box and go into the Properties of that entry field and select Linked Data Source and from select the name you set in 2 above. Then come out of this field and return to your Template view.
  5. From the File>Print screen click on the button to the right of the Copies entry box and choose the Get Quantity from Data Source Option and in the left hand column click on the words Data Source
  6. . Change the Type to VB Script, and then the drop down to Event Controlled Script and press the Edit button
  7. Leave the AutoSelectedEvent as "1" but in the column on the left choose OnIdenticalCopies
  8. Add the following into the central box

Value = Round(Format.NamedSubStrings("DBNumber").Value/Format.NamedSubStrings("NumberInput").Value,0)
Value1 = Format.NamedSubStrings("DBNumber").Value
Value2 = Format.NamedSubStrings("NumberInput").Value

Value3 = 10*(Value1/Value2)
Value3 = Right(value3,1)
If Value3 = 0 then
Value3 = 0
Else Value3 = 1
End if

Value = Value+Value3

The code is a bit rough an ready and there are probably other ways of doing it but I know this works.



Adam Flores Sr


I use this Script to calculate the Quantity printed, Based on Labels Across and And Rows Down

Iworks very well for us, regardless of how many labesl across (and down if you were to fill a Sheet)

Note: Copy and Paste the script below in a Multiline vbScript Data Source.

'Start of Script

mAcross = Format.PageSetup.LabelColumns
mDown = Format.PageSetup.LabelRows
mTags = mAcross * mDown
Lqty = Int(QTY)      'this a Field Shared Name and we are using the Integer value, and not the fractions of the result

IF Lqty Mod mTags = 0 THEN
Value = Lqty
Do Until Lqty Mod mTags = 0
Lqty = Lqty + 1    'Since we used the Integer value and assume that we had a fraction leftover we are adding 1 to make up for the shortage

'Qty to print It will fill the sheet
'Value = Lqty + (mAcross * 2)    ' Remove the comment quote if ypu need to add extra labels to print
Value = Lqty                              'This will print your desired quantity 

Create a Field outside of the Label format and Name It "QTY", That is the Name referenced in the Script above

and then Click on the Print icon and Click on the right side Icon of Copies: to connect to a Data Source.


I hope this resolves your needs.


Adam Flores Sr.

Progressive Label, Inc.


Veuillez vous connecter pour laisser un commentaire.