We assume you already have the code from this article in your database:
http://allenbrowne.com/ser-56.html
Steps:
1. Open the form in design view.
2. In the Properties box, looking at the properties of the Form, on the
Event tab, set the On Current property to:
[Event Procedure]
3. Click the Build button (...) beside this property.
Acdess opens the code window.
4. Set up the code like this:
Private Sub Form_Current()
Call LockBoundControls(Nz(Me.Complete.Value, False))
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
I think this is really going to be helpful....
I hate to bother you, but I think this posting could use a little more
detail:
How do you mean 'call the code in form_current and form_afterupdate',
passing NZ(Me.Complete.value,False)'?
I already have some code in the on current event of the form's but not
in
the after update one.
I guess this scenario of mine does not involve creating the button in
your
download instructions but that a red rectangle is a good idea.
Basically, I need to be able to wrap my mind around the mechanics of
implementing your workaround/suggestion.
TIA
:
Call the code in Form_Current, and Form_AfterUpdate, passing:
Nz(Me.Completed.Value, False)
If the check box is true, this will lock it.
If the check box is false, this will unlock the record.
If the check box is null (e.g. at a new record), it will unlock it.
I've had a chance to implement this code and controls onto my form
and
I
think I understand what it's doing and what it isn't doing. It seems
to
lock
the user out from making any modifications to any records bound to
the
form/subform. What would like is to allow the user to see which
records
have
been entered completely into the database. I currently have a
checkbox
control on it which is bound to a field in the underlying table and
is
called
'Complete'. Its label is red if it's been checked and green if it
hasn't
been
and its status varies from one record to the next as the user
scrolls
through
each record. But it fails to do what your cmdbutton did and that is
prevent
any edits to a record once the checkbox is selected.
Thoughts?
:
Setting AllowEdits to No for a form affects all controls on the
form.
Therefore the subform control is locked well. Even unbound controls
are
unusable.
Here's an alternative approach:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
This is a piece of code that leaves the form's AllowEdits property
unchanged, but sets the Locked property of the bound controls
instead.
The
unbound controls are therefore still usable.
The code does lock the subforms too, but it accepts a list of
controls
to
NOT lock. So, if you tell it not to lock your subform, it leaves it
unchanged.
I have a form which I have locked for edits (in properties) to
avoid
accidental changes to data, and have place a command button on it
to
allow edits.
There is a subform on this form which previously allowed users to
add
new associated records through the normal add record row at the
bottom. However, when I chose to prevent edits on the main form I
found that the add records row in the subform was greyed out.
Clicking
the command button to allow edits to the main form did not affect
the
subform. Has anyone got any idea why is might be happening and
how I
can overcome the problem?