Skip to main content

Search

Search

Using VB Script to change one field based on another

Comments

8 comments

  • Avatar
    trevor callaghan

    Can't help too much, I've only just started to use Bartender VB. If Bartender VB scripting can handle case statements that would be the way to go

     

    Select case value

    Case "AA"

    value = 1

    Case "AB"

    value = 2

    and so on, but this will hard code the values and is not really the correct way to code VB, if you can get help from someone to show you how to get the values from a file then your VB code won't need to change just the file data, and anyone can do that.

    0
  • Avatar
    Peter Thane

    Just checking that you are using a Data Entry Form (Prompt at Print Time screen) in to which the users enter their initials, if not the OnPostPrompt script will not trigger. 

    I have just mocked up something similar here with a Data Entry Form and it works correctly. The only changes to you VB is I have removed the Print Cancel part and instead have set the Data Entry/Form box to require the users enter a minimum and maximum number of characters as 2 otherwise they cannot proceed plus also added a Value = Vale line at the end of the code.

     

    FYI: In later versions of BarTender code like this would not be needed as you can link up a data entry box to either an embedded or a file list box where the users choose/type in a value and BarTender takes either this value or a different value in a second field as the screenshot below is setup. If you use the external file type then if new users are needed you just add this to the text file and save it and BarTender will be bale to use these straight away.

    0
  • Avatar
    Thad Larson

    It might be a revisions constraint.  I am using 9.3.  When I go to make a drop-down box in the prompt design screen, the only options that I see are "Screen Data" and "Visual Basic Script".  I do not have an option for "Embedded Data". 

    I have used database for items like this, but I have not seen Bartender sort by entry and print accordingly.  I usually have to select the records that I want to print.

    0
  • Avatar
    Peter Thane

    Screen Data = Embedded Data the name changed in a later version

    You may not have all the options available in 9.3 as that version of the software was released over 10 years ago and has since been superseded six times with later releases including BarTender 2021 earlier this month. 

    When using the external file method, I mentioned above, this is different to your usual database connection that you suing for populating the data fields and so you don't setup the database queries etc. for this.

    0
  • Avatar
    Lon Empeno

    Hello, 

    I have this field called 'Shif #:', I would like to make this conditional based on the time when the label is being printed. 

    For example, If the time is between 5:00 to 14:00, the field name would print or show 1. If the time is between 15:00 to 1:00, it would print 2. 

    Is that possible? Appreciate any help!

    0
  • Avatar
    Peter Thane

    There are probably other ways of doing this but you can achieve it like this:

    The 10:28 field is the time field. #

    The 10.28 is an Object Value field linked to the time field above with the Type set to Time but using a custom HH.MM config to make it look like a normal number rather than a time for the VB #

    # Both these fields can be dragged off the side of the label so they dont actually print but can be referenced by the VB field

     

     

    0
  • Avatar
    Lon Empeno

    Thanks, Pete.

    I followed your instructions, and I am still getting this error message please see the attached picture.

    OnAutoSelectedEvent (Line 3): Type mismatch: '[string: "10:55"]'

    0
  • Avatar
    Peter Thane

    You have missed this bit

     

    "The 10.28 is an Object Value field linked to the time field above with the Type set to Time but using a custom HH.MM config to make it look like a normal number rather than a time for the VB #" 

    and did not make it a custom time with HH <DOT> MM to replace the : 

    0

Please sign in to leave a comment.