FieldNumber( reports 0 in Call Procedure

Database has 2 fields. Name & Phone.
Procedure A below reports that Phone is field #2

Message "Field Number: " + FieldNumber("","Phone")
Call Procedure_B,Phone

Procedure_B below reports that LParameterFieldName is ‘Phone’ but the FieldNumber is 0.

Local LParameterFieldName
LParameterFieldName = ParameterEntity(1)
Message LParameterFieldName
Message FieldNumber("",LParameterFieldName)

What am I missing? Why is Procedure_B not knowing that Phone is field 2?

The last line of your procedure B is displaying the field number of LParameterFieldName. Since your database does not contain such a field, it displays zero.

To force the fieldnumber( function to use the contents of this variable, instead of the name of this variable, you need to add at least one operator to this formula. Simply appending an empty string will do the trick, like this:

Message FieldNumber("",LParameterFieldName+"")

If you review the documentation for the fieldnumber( statement, you’ll see a detailed explanation of this behavior (which is expected and correct, i.e. it’s a feature not a bug!). See the Using a Variable for the Field Name section of this page.

That help page states that I should have gotten an error but I did not get an error, I just got ‘0’.

FWIW, I had tried this but apparently not all formulas work the way Pano needs to force the trick. Yes, I get that I was just quoting the variable.

Message FieldNumber("",'"'+LParameterFieldName+'"'')

Where do you see it says that? What I see it says is that “If the requested field does not exist, the function returns zero.” Which is what it does.

You must supply a formula that calculates the field name. Your formula doesn’t. There is no field named "Phone" in your database, so zero will be returned. In this case, the formula result must be Phone, the actual name of the field. In this example there is nothing special about the " character, it is just a character.

Hmm, it also appears to me that this line of code has an extra ' character, so I don’t see how this code would even compile without an error.