VFP 6 (Visual Foxpro 6) Error

Hi, I am trying to figure out what the correct syntax is to fix the error in the attached .jpg. I am using VFP6.

Thanks in advance,

Charlie VFP6 Error
Who is Participating?
Olaf DoschkeSoftware DeveloperCommented:
You can't keep it numeric, as you want to add it into a string.
And Alltrim() does NOT convert to a string, it just trims a string, STR() converts to a string.

All I was already saying is you need to make this correction:

If Found()
   HoldThisSAPCaseQty = STR(product.case_qty)
   HoldThisSAPCaseQty = "FNF"

I hope this makes it clearer.

Bye, Olaf.
Olaf DoschkeSoftware DeveloperCommented:
You give the reason yourself: product.case_qty is a numeric field. You can't use alltrim() - which is a string function - on a numeric value.

While an N(5) field stores it's numeric values in string format in the dbf file, it is converted to numeric (double) in memory, so your if found() else endif is setting HoldThisSAPCaseQty to a numeric value in the if case and the string "FNF" in the else case.

You would need STR(product.case_qty) to make HoldThisSAPCaseQty a string in both cases.

Bye, Olaf.
cafulfordAuthor Commented:
Hi Olaf,

I was only trying to convert it to a string because I was not sure how to get it embedded in:
strLbl = strLbl + "^FO25,65^BY.33^B3N,N,30,N,N^FD" + AllTrim(HoldThisSAPCaseQty) + AllTrim(label.cust_prod) + "^FS" + CRLF

What is the syntax for adding that field into the statement if I want to keep it numeric?


You have to convert it to the string otherwise you cannot embed it into the string.

Simply do what Olaf suggested or use TRANSFORM function:

HoldThisSAPCaseQty = TRANSFORM(product.case_qty)

on appropriate place.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.