Order of Execution on Named Data Sources of VB Script type
I have a named data source that is Single-Line VB Expression, which takes input data from two pieces of input data, extracts the serial numbers (27,8), ensures that they aren't the same, then concatenates them for the final print.
Named Data Source: eSerialCombine
Expression:
IIF(Mid(Format.NamedSubStrings("vSerial1").Value,27,8)=Mid(Format.NamedSubStrings("vSerial1").Value,27,8),"ERROR",Mid(Format.NamedSubStrings("vSerial1").Value,27,8)&"-"&Mid(Format.NamedSubStrings("vSerial1").Value,27,8))
It prints correctly, showing ERROR if they match, and the concatenated value if they don't.
However, I can't figure out how to use this named data source in the Form Actions Validation. It seems that it's not being evaluated until after the validation occurs.
In the Validate Data section of the Form Actions, I've shown a message box with the input data variable (vSerial1) and it shows properly. I've then shown a message box with the VB Script expression data (eSerialCombine) and it's blank.
I've tried making it an event control script as well, but can't seem to find the proper event for it to run after the Print Button is selected, but before the Data Validation runs in the Form Actions.
How can I get the expression to execute in the Validate Form section of Form Actions, or how can I validate this data on the form to stop the print job if the user enters invalid data?
This behavior should be reproduceable by simply making a VB Script named data source x="Hello world," and making an Embedded Data source y as a text input on the form. Then in the Form Actions under Validation add an action to display a message for each variable. Click on print preview, enter data in the form such as "test input," and submit the form. You'll see the x's message is blank, but the y's message appears.
BarTender Designer 2022 R5
-
Peter Thane
★ BarTender Hero ★
One drawback of the VB option is there not of the Event Controlled Options can be processed mid Data Entry Form and so that wont work.
For the Form Actions however you should be able to do something as you can have more than one form and run the action as a form closes or a new one opens and display you messages on there perhaps adding a button that would return the user back to the previous form etc.
1 -
Rich Calligan
★ BarTender Hero ★
Thanks Peter Thane. Are you saying that the VB script should run in between forms? So I could have one data entry form, then the script evaluates the expression before the next form pops up, and that next form could check the values?
Otherwise, what is the normal workflow for use cases like this where more advance validation and data extraction is required upon input?
0 -
Peter Thane
★ BarTender Hero ★
No you cannot run VB between forms but you can process as Action at this time.
For the VB you can only run pre prompt (ie before processing the Data Entry options) or post prompt (after all the Data Entry screen have been completed)
0 -
mark reber
★ BarTender Hero ★
Hello
How would I run a VB after the form is filled out?
thanks
0 -
Peter Thane
★ BarTender Hero ★
You need to make the label field have the Type set to Visual Basic Script and choose the Event Controlled Script and then select OnPostPrompt as the time when the VB will be processed
0
Please sign in to leave a comment.
Comments
5 comments