VB Script works in version 10.1 but not in version 2016 S’abonner

0
Avatar
Kevin

I have a very simple script pulling a Boolean value from a database as follows:

IF Field("Tbl_LabelTemp.Statement") = True THEN

Value = "Print this statement"

END IF

This label was originally created in Enterprise Automation version 10.1, but we've now converted to Enterprise Automation 2016 and this one field in this label results in an empty value in the field.  All other database values are populating.  The script works perfectly in version 10.1. 

Furthermore, in version 2016, if I change the script to be this:

Value = Field("Tbl_LabelTemp.Statement")

The field populates on the label as "True", so I know the script is seeing the correct value, it simply is not printing the string I'm asking it to print when it sees the "True" value in the database.  The data type setting of the label field is text.

Very puzzling.  What am I missing?

3 commentaires

0
Avatar
Kevin
Actions pour les commentaires Permalien

I figured this out.  The script will work if I put the True in quotes like this:

IF Field("Tbl_LabelTemp.Statement") = "True" THEN

Value = "Print this statement"

END IF

Maybe this is because the label field is a text field, not sure.  It seems odd that the boolean value from the database is seen as a string by VB.

I have a related issue I've yet to solve however.  I have a picture that I want to print or not print based on another boolean value in the database.  When I use the "Print When" functionality and select this boolean field in the database to base the condition on, it will only allow numeric values to be entered as the conditional value to test.  If I enter a 1 or a 0, it does not return the expected result.  I've tried forcing it to be "true" in the "Conditionally, based on expression" area, but what I type in won't save unless it matches what the function recognizes as being the data type of the database field evidently.  It looks like the numeric values include decimal places, so maybe this is why its not recognizing that 0 = false and 1 = true.  Maybe it can't handle true/false conditions.

Any advice?

0
Avatar
Kevin
Actions pour les commentaires Permalien

Solved the 'Print When' problem by changing the database to be a text field with a drop-down list of values.  Couldn't find a way to make a boolean value recognized in the 'Print When' conditional statement.

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

For the picture you could just go down the suppression route rather than using VB.

  1. If not already on the label add a field to the side of the label itself linked to the field in the database that governs whether the image prints or not and give this label field a name via the Data Source Tab > Change Data Source Name Button
  2. If it is not already, make the Picture an External Picture File>Get file name from Data Source and browse to you image folder.
  3. Click on the Data Source to the left and add in the name and file extension of the image in Embedded Data field
  4. Click on Transforms and Suppression and set up Condition Suppression (Suppress when the following is true option) using the label field name specified in 1 and "Equals" what ever your value is that stops the image from being printed 

I hope this helps

Pete

Vous devez vous connecter pour laisser un commentaire.