Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting Column ControlSource to an Expression
Message
From
08/12/2008 06:43:12
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
08/12/2008 05:28:03
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01365914
Message ID:
01365922
Views:
10
>Greetings all.
>
>I know that I know this, but I can't for the life of me dredge it out of my brain, so I'm figuring that if I ask here it will probably come to me seconds after I hit Send :-)
>
>I have a column in a grid and I want the ControlSource to be an expression rather than just a field. For example -
>.ControlSource = "MyUDF(MyField)"
>This is working a lot of the time but every now and then I get a "variable is not found" error even though the MyField is in the RecordSource and the RecordSource is the currently selected table. I thought that ReadOnly had something to do with it, but that doesn't seem to help. If I do -
>.ControlSource = "''+MyUDF(MyField)"
>(That's two single quotes there on the beginning) it works. It's like VFP is thinking that MyUDF(MyField) is an array reference.
>
>Does anyone know how to stop the error other than adding an empty string there at the beginning? I assume that I'd have to add 0 to numeric values etc, and since this is for some generic code, making sure that it knows the possible return value types from MyUDF is a bit tricky.
>
>Ian Simcock.

I had problems with this in the past. This happens when a UDF has 1 or 2 parameters. Add useless and unused parameters, for a total of 3.

Well, I had this problem in an older version of Visual FoxPro, but the problem may still be around.

Perhaps some other workaround could work as well, for example,

"" + MyUDF(MyField) && for type "C"
0 + MyUDF(MyField) && for types "N", "I", "D"
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform