Skip to main content

Search

Search

Vb Script On Validation At Prompt Dialog

Comments

9 comments

  • Avatar
    Gene Henson
    Hello,

    The easiest way to configure this is actually to set a minimum value (minimum here refers to the length of the string) for the underlying object that you are prompting for. You can set the minimum value to one. Then, if the prompt is left blank at print time, the user will be prompted that the minimum value was not met. They will then have the option to Pad the string with data you specify, return to the Prompt Dialog, or cancel the print job all together.

    In BarTender 9.4 you will configure this in the "More Options" dialog. See the below screenshot:

    [attachment=152:9.4 Minimum.bmp]

    For the good of the order, here is the how you configure this in 10.0:

    [attachment=153:10 Minimum.bmp]


    This may not be a perfect solution for you because it could allow a print operator to accidentally print the label with padded values instead of typing in the correct information. There are two ways you can work around this:

    [list=1]

    [*]You can change the default response to this message to "return to prompt dialog" and then turn off the interactive dialog. This will ensure that users are always returned to the prompt dialog if the prompt is left blank. See below for instructions on this.
    [*]As you suggested, you can create a VB Script to handle this scenario. The issue here is that there is no way to return to the prompt dialog via VB Script. So your only option would be cancelling the print job. See below for instructions on that.
    [/list]

    [b]To change BarTender's Message Setup:[/b]
    [list=1]
    [*]Go to Administer > Application Message Setup.
    [*]Find the message you would like to change, in this case it is Message 2603.
    [*]Choose your "default" response.
    [*]Un-check Dialog (Interactive Use Only)
    [/list]
    See this screenshot:

    [attachment=154:Message Setup.bmp]

    [b]VB Script to check length of field:[/b]
    [list=1]
    [*]Give the data source in question a unique name.
    [*]Create an event controlled VB Script (off the design area).
    [*]Choose the Post-Prompt event.
    [*]Enter in the below VB Script.
    [/list]

    [code]If Format.NamedSubStrings("Field1").Value = "" Then
    Format.CancelPrinting("Field 1 cannot be left blank. Please cancel and try again.")
    End If
    [/code]

    Let me know if any of that will work for you.
    0
  • Avatar
    Legacy Poster
    Yes, i have tried the vb script. It worked so far except that it couldn't return to the prompt dialog just as you mentioned.
    I will try look into it further.Thanks for the help.
    0
  • Avatar
    Legacy Poster
    I have a script that does this. I have 2 objects on the label related to this field. One is off the printable area and is just a sub-string that is prompted, like what you have. It is called "EnteredInit".

    Then I have the actual printed field, which is populated by a VB script under OnIdenticalCopies. But you could probably put it OnPostPrompt too and get the same thing. Here is the code for that:

    [code]Value = Format.NamedSubStrings("EnteredInit").Value

    if (Format.NamedSubStrings("EnteredInit").Value = "") then
    Value = InputBox ("Appears as if you forgot to enter your intials. Please enter below:", "Author Initials")
    end if
    [/code]

    The code first assigns the printed field to the user-entered data. Then it checks if that field was not filled in, and prompts the user to re-enter the data. That data is then used for the printable field.
    0
  • Avatar
    Legacy Poster
    Hi nRder,

    Thanks for the reply. Your script that provided has given me some ideas.However, i got stuck in the following script

    [code]
    If Format.NamedSubStrings("EmpNo").Value = "" Then
    Format.Objects(InputBox ("Employee No cannot be left blank. Please enter it:", "Error Message"))
    Format.NamedSubStrings("EmpNo"). Value =Format.Objects(InputBox ("Employee No cannot be left blank. Please enter it:", "Error Message")).Value
    Else
    Value = Format.NamedSubStrings("EmpNo"). Value
    End If
    [/code]


    The message box is working if i left the employee no field blank.But when i enter some sort of number into the message box,it suppose to show the number in the employee no textbox in prompt design, but i get the following error msg

    OnPostPrompt(Line5): : Type mismatch: 'Format.Objects'

    Any idea? Any help would be appreciated.Thanks
    0
  • Avatar
    Shotaro Ito
    When you want to show warning and option to return to Form(prompt), try this:

    When this datasoruce is empty, show warning and option to return to form.

    Transform(More options) > VBScript > OnProcessData:
    [code]If Value = "" Then
    Format.CancelPrinting "Please input any value to [EmpNo:]"
    End If[/code]

    When you want to show option to continue printing..
    [code]If Value = "" Then
    Format.CancelPrinting "[EmpAge:] is empty. still want to print?","Continue"
    End If[/code]

    [attachment=181:CustomValidation.png]

    Sample[attachment=182:CustomValidation.btw]
    0
  • Avatar
    Legacy Poster
    [quote name='tbzserge' timestamp='1333001467' post='2097']
    The message box is working if i left the employee no field blank.But when i enter some sort of number into the message box,it suppose to show the number in the employee no textbox in prompt design, but i get the following error msg

    OnPostPrompt(Line5): : Type mismatch: 'Format.Objects'

    Any idea? Any help would be appreciated.Thanks
    [/quote]

    Well, you haven't copied the syntax of my code very closely. I don't think you need to put the InputBox inside a [i]Format.Objects()[/i], and that may be your issue. I'm not sure. Again, with my layout, I actually had 2 fields on the template. One was prompted, and the other was scripted to pull from the first one, unless it was blank, then it prompted for an inputbox.
    0
  • Avatar
    Legacy Poster
    Doing some validation where the quantity of label
    should not larger that the Last Running No.

    Using the above script, but somehow end up looping during the prompt time
    Is there anything i miss?
    0
  • Avatar
    Shotaro Ito
    [quote name='kai' timestamp='1340617654' post='2660']
    Doing some validation where the quantity of label
    should not larger that the Last Running No.
    [/quote]
    Hi Kai,
    As I understood, you cannot properly detect user input of other text box, on Data Entry form's OnProcessData event.
    (correct me if I'm wrong)
    So there's no perfect solution for that. one thing you can try is, create another text object as Event Control Script source,
    in [OnPostPrompt] Event, validate two text's values and show error by CancelPrinting() function.
    (Note OnPostPrompt event's CancelPrinting function doesn't give you an option to return to DataEntry form, unlike OnProcessData.)
    0
  • Avatar
    Legacy Poster
    [quote name='Shotaro I -Seagull Support' timestamp='1340773259' post='2690']
    Hi Kai,
    As I understood, you cannot properly detect user input of other text box, on Data Entry form's OnProcessData event.
    (correct me if I'm wrong)
    So there's no perfect solution for that. one thing you can try is, create another text object as Event Control Script source,
    in [OnPostPrompt] Event, validate two text's values and show error by CancelPrinting() function.
    (Note OnPostPrompt event's CancelPrinting function doesn't give you an option to return to DataEntry form, unlike OnProcessData.)
    [/quote]


    Thanks for your guide. i've try many way on this but never try to create an event script.
    0

Please sign in to leave a comment.