Problem : What means vfp message: object is not contained in a form

Problem : What means vfp message: object is not contained in a form

Hi ,

Do you know what it means and the workaround ?

“object is not contained in a form”

Amazingly it appears in a chunck of code aparently with no relation with the bug.

Thanks in advance.


Solution : What means vfp message: object is not contained in a form

Yes exactly. The filter should be independent on any variable and/or object. You never know where and when it can be evaluated.

The macro substitution for a string constant is possible solution in this case but it is static. To “simulate” the dynamic behavior you have to execute SET FILTER command whenever the variable contents change.

Another option is to place the filter value into a new _screen property which is better than variable and which remains dynamic:

_screen.AddProperty(“MyFilter”,”FilterValue”)
SET FILTER TO SB_EMP = _screen.MyFilter

Above property will always exist (after the first definition) and is always visible not like variable.

BTW, if you have index on SB_EMP column then you could use SET KEY instead of SET FILTER which is much faster.