VFP evaluates the ControlSource more often than you might think

When you activate or deactivate a form, VFP evaluates the ControlSource several times, even thoughRefresh isn't called, at all. As long as the ControlSource expression is valid, that's hardly an issue. Invalid ControlSources, however, show a peculiar behavior. In this case we're talking about propertiesbeing the ControlSource.
However, if the ControlSource is a property of an object that doesn't exist anymore, the first VARTYPE-like
test fails. In this case, you get the error message already when you deactivate the form, not when you re-activate it. In
my particular situation this error message finally ended in a C5 error. Here's a program that demonstrates that
VFP attempts to access the control source when you deactivate the form:


Clear
Public goForm
goForm = CreateObject("MyForm")
goForm.Show()

Define Class MyForm as Form
Left = 150
oItem = NULL
Add Object myCheckbox as Checkbox with ;
ControlSource = "Thisform.oItem.lSource"
Procedure Load
This.oItem = CreateObject("myItem")
EndProc
Procedure Refresh
Activate Screen
? "Refresh"
EndProc
EndDefine

Define Class myItem as Custom
lSource = .T.
Procedure This_Access( tcProp )
Activate Screen
? "myItem." + m.tcProp
Return This
EndProc
EndDefine