Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2566
  • Last Modified:

How do I declare a field in VB Script

Hi,

I am using the VB Script editor within a canned barcode application (BarTender) to perform some testing.  When the following code is executed, if it is false, the correct value prints.  If it is true, I receive the follow error:
OnProcessData(Line2): : Field name FIRM_LABEL_SETUP.Customer PO # has not been declared.  To declare a field for a script insert DeclareField("FIRM_LABEL_SETUP.Customer PO #") at the top of your script, such that it is not wrapped in any control logic.
if Field("FIRM_LABEL_SETUP.Label Data 1") = empty then
Value = Field("FIRM_LABEL_SETUP.Customer PO #")  
else
Value = Field("FIRM_LABEL_SETUP.Label Data 1")
end if


After following the first message and entering the code that follows, A new error message displays:
The following scrip error war found
OnProcessData(Line 1): : Type mismatch: "DeclareField"


DeclareField("FIRM_LABEL_SETUP.Customer PO #")
if Field("FIRM_LABEL_SETUP.Label Data 1") = empty then
Value = Field("FIRM_LABEL_SETUP.Customer PO #")  
else
Value = Field("FIRM_LABEL_SETUP.Label Data 1")
end if


Any idea?


Thanks
Mc
0
mcain_bba
Asked:
mcain_bba
  • 2
  • 2
1 Solution
 
ClifCommented:
Wrap the field name (within the quotes) in square brackets:

Value = Field("[FIRM_LABEL_SETUP.Customer PO #]")

Use your original code
0
 
mcain_bbaAuthor Commented:
The error message did not change after adding the [] to the code

if Field("FIRM_LABEL_SETUP.Label Data 1") = empty then
Value = Field("[FIRM_LABEL_SETUP.Customer PO #]")  
else
Value = Field("FIRM_LABEL_SETUP.Label Data 1")
end if
0
 
mcain_bbaAuthor Commented:
The following code fixed the problem.  I must confess, I do not understand why one field needed to be declared and not the other.

I am going to award some points for working with me.

Thanks
mc


Dim A
A = Field("FIRM_LABEL_SETUP.Customer PO #")

if Field("FIRM_LABEL_SETUP.Label Data 1") = empty then
Value =  A
else
Value = Field("FIRM_LABEL_SETUP.Label Data 1")
end if
0
 
ClifCommented:
Hmmm...

Maybe it should have been:

Value = Field("FIRM_LABEL_SETUP.[Customer PO #]")

Glad you got it working though.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now