subform's source object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

show data from subform in master form 5
subform problems 6
Form View 1
SubForm Issue In Main Form Datasheet View 2
Requery unbound textbox 1
Access Subform in MS Access 2010 0
2 same subforms 1
ZoomBox help 1

Back
Top