Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Control Source Error

Control Source Error

Control Source Error

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

RE: Control Source Error

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 =.

RE: Control Source Error

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 =.


RE: Control Source Error

Thanks a lot .. the problem has been solved

RE: Control Source Error

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

RE: Control Source Error

thanks very much Olaf.

RE: Control Source Error

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

IIF((table1.exam_1 + table1.exam_2) > 85, "Excellent")

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

IIF((table1.exam_1 + table1.exam_2) > 85, "Excellent", "Other")


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Control Source Error

I already comment on that in my first reply.

RE: Control Source Error

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

RE: Control Source Error

If you prefer to misunderstand, then that's your choice.

RE: Control Source Error

Now everything is fine
thank you all

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close