Solved

How do I declare a field in VB Script

Posted on 2006-12-01
4
2,389 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 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