Right. if you add the grid to the form when there is nothing open in the "underlying" workspace, the recordsource is empty when queried. So that's why the default framework (VMP) code was turning back and not firing the rest of its setup methods (which is not the best design, but then the codebase for VMP has not been updated for probably a decade; I suspect that this would have been re-engineered at some point to not do this but to only turn back if some development mode flag said so).
Albert
>Nice trick. So
>
>USE companys
>SELECT 0
>loform=CREATEOBJECT("form")
>
>
>creates a grid w/o anything?
>
>>Just a quick update - I did not know this before but if you instantiate a grid on a form, it *assumes* the recordsource whatever table/view is open in the current workspace if you do not specify this specifically in the setup e.g.
>>
>>
>>USE companys
>>loform=CREATEOBJECT("form")
>>loform.AddObject("TestGrid","grid")
>>? loForm.testgrid.RecordSource
>>
>>
>>Result: .Recordsource = "companys"
>>
>>I would have thought .Recordsource would be empty if not explicitly set on the designer screen.
>>
>>Albert