Solved

How do I declare a field in VB Script

Posted on 2006-12-01
4
2,465 Views
Last Modified: 2012-06-27
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
Comment
Question by:mcain_bba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Clif earned 500 total points
ID: 18054485
Wrap the field name (within the quotes) in square brackets:

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

Use your original code
0
 

Author Comment

by:mcain_bba
ID: 18054693
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
 

Author Comment

by:mcain_bba
ID: 18054818
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
 
LVL 10

Expert Comment

by:Clif
ID: 18054856
Hmmm...

Maybe it should have been:

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

Glad you got it working though.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month4 days, 7 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question