Multiply With VBA
I have two fields
IF_API_SampleDB.UOM_pluralabbreviation - BX - 12
IF_API_SampleDB.custrecord_packship_totalpackedqty - 6
I have create a text box using embed data type named it outputfield and vb on the transforms to attempt to strip IF_API_SampleDB.UOM_pluralabbreviation to get just any numeric after the dash and then multiply that by IF_API_SampleDB.custrecord_packship_totalpackedqty to get the full quantity in eaches.
Private Sub OnAutoSelectedEvent()
Dim qty_field As Field
Set qty_field = Format.Fields("IF_API_SampleDB.custrecord_packship_totalpackedqty")
Dim uom_field As Field
Set uom_field = Format.Fields("IF_API_SampleDB.UOM_pluralabbreviation")
Dim uom_qty As Integer
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
regex.Pattern = "\d+"
Dim matches As Object
Set matches = regex.Execute(uom_field.Value)
If matches.Count > 0 Then
uom_qty = CInt(matches(0))
Else
uom_qty = 1
End If
Dim total_qty As Integer
total_qty = qty_field.Value * uom_qty
Dim output_field As Field
Set output_field = Format.Fields("OutputField")
output_field.Value = total_qty
End Sub
Im getting a syntax error
OnProcessData (Line 1): Private Sub OnAutoSelectedEvent(): Syntax error
Any ideas?
-
I would suggest adding the VB into a dedicated VB substring rather than use the Transforms option and, depending when your data is entered perhaps make this an Event Controlled Script to run at a specific time during the printing process
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar