Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Source Error

Status
Not open for further replies.

ameedoo3000

IS-IT--Management
Sep 20, 2016
233
EG
Hi all
There was a problem selecting the data source with expression builder As shown in the pictures below.
Please explain why and solve the problem
Greetings
ِAhmed
a_koql7e.png

e_etue99.png

b_gldusc.png

c_moty7n.png

d_oqsra8.png
 
Without studying too much, I notice that the IIF() statement misses a parameter, the "else" value. I haven't used this type in many years, but I seem to remember that the expressions also must be preceded by a =.
 
Tore hit it on the nose. To specify something other than a field as the ControlSource in a grid, you need to precede the expression with =.

Tamar
 
No, a controlsource expression (other than simply a field) always needs to be enclosed with brackets, not preceded by a "=".
A controlsource is evaluating its value anyway, but this fails even with simple expressions and leads to the error. This is an old known misbehaviour of the controlsoure.
If you prefix an expression with "=" in the controlsource, you only cause a one time evaluation of that expression and the result has to be an expression you want as controlsource.
If you set controlsource to "=exam_1+exam_2" you would set it to whatever number and that won't work out at all, Tore, Tamar.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Regardless of the fact that the control source needs to be enclosed in parentheses or preceded by an equals, your actual expression is incorrect:

[tt]
IIF((table1.exam_1 + table1.exam_2) > 85, "Excellent")[/tt]

You need three arguments to IIF(): the condition, the "true" expression, and the "false" expression. So something like this would be better:

[tt]IIF((table1.exam_1 + table1.exam_2) > 85, "Excellent", "Other")[/tt]

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, you gave the wrong recommendation of preceding with "=", that's not the solution, also not setting the controlsource ="exam_1+exam_2"

Edit: I tried, this works, but then also exam_1+exam_2 as was initially done. Maybe the latest Hotfix finally fixed that, I'd still always use bracketing. In that case VFP never tells you controlsource "must be a variable reference".

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top