local ac ac = thisform.ActiveControl do case case vartype(ac) <> T_OBJECT && grid does not have the control otherwise && from here on you can test different properties of ac && like BaseClass, Class, ControlSource, ... && to determine whether it is the grid or textbox you are after endcase