> Right. If I comment it like this:
>
>*!* if TYPE(lafieldlist[i])="L"
>*!* lbValue=&lafieldlist[i]
>*!* lcValue = "IIF(lbValue,'N','Y')"
>*!* This.columns(i).controlsource=lcValue
>*!* else
> This.columns(i).controlsource = lafieldlist[i] && Assign controlsource
>*!* endif
>
> the grid appears fine.
Now try this:
if TYPE(lafieldlist[i])="L"
This.columns(i).controlsource=[IIF(]+lafieldlist[i]+[, 'N', 'Y')]
else
This.columns(i).controlsource = lafieldlist[i] && Assign controlsource
endif
I think it's the macro in the upper version which stuffed the value of the field, and not the field's name into lbValue. You don't need the value here, you need the name, and the IIF() will return a value at runtime.
> If Not empty(PrevFocus)
> THISFORM.&PrevFocus..SetFocus()
> endif
> Am I right?
>
> So, we need to change our classes this way, right? So, I have another question - how can I check that this property exists on my form? Because I can not assign if the property doesn't exist...
You'd have to change both the controls' classes and the form's class, just to make sure that it actually has the property you need. You may try to check thisform.activecontrol in the button's when event - it may be just early enough before the previous control loses focus. This may not be sure, you have to check for accessing the button via mouse, in regular tab order, or via a hotkey. I've observed different firing sequences of the button's events, so your mileage may vary. Still, I seem to remember that during the button's When event, the button is not the Form.activecontrol yet (if you press a hotkey and When return's false, the button should never get focus), so it may be worth trying.
I can't try at the moment, because most of my VFP is scrambled after several powerouts these days. I hope it will be enough to just restore Foxuser from backup... last time I had to reinstall a lot.