subform's source object

R

rico

i have a subform on my mainform. the subform is in datasheet view and i want
to lock a certain field in that view. how do i do it? note that the subform's
source object is a query and is in datasheet view.
 
A

Arvin Meyer

The subform's Source Object is a form. It's Row Source is a query. You can
lock the field from the main form when it fires an event with the following
syntax:

Me.NameOfSubformControl.Form.ControlName.Locked = True

The NameOfSubformControl is the name of the control on the main form NOT the
name of the subform (although the 2 can be the same). You can put the line
of code in the main form's load event or Open event to lock it
unconditionally. Or use the Current event if you want to lock/unlock it
conditionally. You can also lock it from the subform because you can't touch
the subform without it getting focus. Keep in mind you can always write to a
locked control in code, just not from the keyboard. If you want to keep code
from altering the data, disable the control.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
R

rico

i tried that and it worked fine. but whenver the source object of the subform
is changed via code, the properties of the control i want to lock is not
retained. i want this control locked badly.
 
Top