Thanks very much. It was the Me.NewRecord field that I was searching for.
Perfect.
I was wondering about the case statement in the loop that visits every
control. I gather it is necessary to hit only certain types of controls?
What would happen if you just did this:
For Each ctl In frm.Controls
ctl.Locked = True
Next ctl
If I want to remember the preferred state of each control where is the best
place to store that? Is there am (easy) way to attach some data to each
control?
Answers in line:
> Thanks very much. It was the Me.NewRecord field that I was searching for.
> Perfect.
[quoted text clipped - 6 lines]
> ctl.Locked = True
> Next ctl
Some controls, like command buttons and tab controls don't have a locked
property. You could just ignore the error (like my code does) and go on, but
I also use a version of that code to disable controls and to read the Tag
property for different actions.
> If I want to remember the preferred state of each control where is the best
> place to store that? Is there am (easy) way to attach some data to each
> control?
You can set the state in the property sheet and the form will open with
those values. Setting the recordsource of the form to a table, query, or sql
string, and then binding the controls to fields will attach data to each
control by records. To set "values" to accomplish certain actions, you can
use the TAG property.

Signature
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
Roland Alden - 10 Mar 2005 04:49 GMT
Ah, the tag property. Just what I was looking for. Thank you.
Now, one other question. I see that subforms have a Locked property that is
apparently forced on the underlying form. This is nice because it means you
don't have to do a "deep walk" of the whole tree to lock all the controls.
However, I do like to set the background color of locked controls so the
user has a visual cue. I could probably put some general code in each
subform's current to walk the controls and color them or some such.
But my real question is why am I walking the top level form at all? Can I
just set the top level forms' Locked to true?
If a subform object on the top level has a Locked property is there some way
to access its state from the underlying subform?
Arvin Meyer - 11 Mar 2005 12:26 GMT
In Access, a subform is a control, like a textbox, until it has focus. Then
it becomes a form.
The locked property is a control property, not a form property. Controls
have a Parent property. The parent of a subform is a form. So you can
traverse up and down the levels, but you can only lock controls, not forms.
(I hope that makes some sense)
Forms can have their editing attributes disabled.

Signature
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
> Ah, the tag property. Just what I was looking for. Thank you.
>
[quoted text clipped - 10 lines]
> If a subform object on the top level has a Locked property is there some way
> to access its state from the underlying subform?