Skip to main content

Search

Search

Print-Dont Print Based On Database Value

Comments

9 comments

  • Avatar
    Legacy Poster

    Sorry for bumping this up but I really need help on this...

    0
  • Avatar
    Ian Cummings
    Moderator

    Create an object that sources the database field in question and then generate a VB script in the OnProcessData script of the data source.

     

    If value <> "PN123" Then
       value = ""
    End If
    
    0
  • Avatar
    Legacy Poster

    I have a similar requirement but it involves two database fields. Our Item# is set to print on all labels and I have that item# coming from a database (item.item). On on the general tab of that object, I have a prefix of MSG# so when the item.item prints it will print MSG# 123456. Some customers do not want our item number to print on their case labels. In our database I have an additional field called (item.print) that will contain an "N" if we are not to print our item# nor the MSG# prefix on their labels. When the field does not contain an "N" the field will be blank or may contain a "Y". We want to print the MSG# as long as that field in not an "N". How can I omit printing of the item# field (item.item) and prefix based on the test of the item.print field content?  Possibly replace the item field with blanks on the label if the print field is a "N". When the operator prints the label they only enter the item# and the number of labels, they don't know if the MSG# should print or not, that is strictly controlled by the database itself. 

     

    0
  • Avatar
    Michael Toupin (mtoupin

    You would do the same thing, just reference the other field.  So:

     

    If field("Database1$.ItemPrint") = "N" then Value = ""

     

    or use a sharename, in which case it would be

     

    if Format.NamesSubStrings("ItemPrint") = "N" then Value = ""

    0
  • Avatar
    Legacy Poster

    I am entering that script in the properties of the ("items.items") field of the label in the options VBscript tab. 

    That field contains the item# of the product that I want to print blanks instead of the item# in the database if

    the other database field ("items.PRT-MSG# Y-N") field contains the value of "N"

     

    I entered
     

    If field("items.PRT-MSG# Y-N") = "N" then Value = " "

     

    End If

     

    I get a Script error End If: expected 'Sub' >  

    What is it expecting?

    0
  • Avatar
    Ian Cummings
    Moderator

    The usual way of writing an If..Then statement is:

     

    If Field("items.PRT-MSG# Y-N") = "N" Then
        value = ""
    End If
    

    By the way: It might be of use to specify a default value for the field reference.  If so, you would supply a second argument to the Field() function.  The below example gives a default value of "N" prior to any print time connection to the database for an actual value to use:

    If Field("items.PRT-MSG# Y-N","N") = "N" Then
       value = ""
    End If
    
    0
  • Avatar
    Legacy Poster

    Thanks for your help, I got Item number to not print when the print/don't print field has a "N" in it but it still prints the prefix of MSG# with no number after it. The MSG# was entered on the general tab on More Data Source Options as Adjacent Text in the Prefix field. Anyway to reference that too in order to eliminate the printing of the MSG# when we have chosen no to print the actual item#? 

    0
  • Avatar
    Legacy Poster

    I look through the topics on the form about "Print" or "Not Print" but it seems all the solutions involve blanking out the field rather than setting the Print/Do Not Print radio buttons through VB. I'm trying the eliminate a barcode from printing by setting the Do Not Print control. Blankiing out the field just gives me a barcode for blanks, I don't want any barcode printed if the item they are printing has a T in a tote field in the database they query for label data. I saw a reference to the Do Not Print in the Help text on the general tab of the object but don't see how I can use that object name in a VB script.

    btObject.DoNotPrint = True

    0
  • Avatar
    Ian Cummings
    Moderator

    If you set the print method of the barcode to be controlled by BarTender, then the whole barcode will always disappear when you set it to have no data.

     

    For information on how to control the "PrintVisibility" VB script property of a label object I suggest you take a look at the below white paper:http://www.bartenderbarcodesoftware.com/label-software/whitepapers/Dynamically-Changing-Objects-At-Print-Time-Using-VB-Script.pdf

    0

Please sign in to leave a comment.