Hide Object Based On Db Field Follow

0
Avatar
Legacy Poster

I am trying to hide 2 fields based on the value of the database field.  I'm using 10.0 and am doing the VB script at the document level OnNewRecord.  The script is below.

 

IF (Field("printpalletfilm_label.cartons") = 0) Then
Format.Objects(Field("printpalletfilm_label.cartons")).PrintVisibility = False
Format.Objects("RLCT").PrintVisibility = False
Else
Format.Objects(Field("printpalletfilm_label.cartons")).PrintVisibility = True
Format.Objects("RLCT").PrintVisibility = True
END IF

 

When I try to test it or close out, I get the message 'OnNewRecord(Line 5): The object 12345678 was not found'.

 

Can someone please help?!

3 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

You're specifying a database field as containing the name of the object that you wish to set print visibility upon.  However, the field value only has a value in it at print/preview time unless you also set a default value for the field reference.

 

Example: Field("printpalletfilm_label.cartons","RLCTEXP")

 

The second parameter for the Field() function allow you to set a valid default, thereby allowing you to avoid errors like this at design time.

0
Avatar
Legacy Poster
Comment actions Permalink

I wasn't sure which line to put a value in, so I did it on all lines.  Now I'm getting the error 'The object 0 was not found'.

 

 

IF (Field("printpalletfilm_label.cartons","0") = 0) Then
Format.Objects(Field("printpalletfilm_label.cartons","0")).PrintVisibility = False
Format.Objects("RLCT").PrintVisibility = False
Else
Format.Objects(Field("printpalletfilm_label.cartons","0")).PrintVisibility = True
Format.Objects("RLCT").PrintVisibility = True
END IF

 

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

You need to specify a default that corresponds to an actual label object name.  As the error message states, there is no object named "0" in your label design.

Please sign in to leave a comment.