Re: Prevent edits - unexpected effects

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You place the code into the events of the form you want to lock.

In code, use
Me
rather than
[Form]

I won't be able to follow up on this over the next week or two. Hopefully you will be able to take it from there.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Access User" <AccessUser@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:237446C2-13F4-400F-84A9-6CAE06EB0B17@xxxxxxxxxxxxxxxx
I have created a 'parent' form into which I am placing the form where all
this was going on before and I believe I ought to be putting the calls into
the same events you cited in your response (below) into the 'parent' and
removing them from the sub-form. Am I correct?

Here are the calls as written

Private Sub Form_AfterUpdate()

Call LockBoundControls([Form], Nz(Me![tbl_MRA_Form].Form!Complete.Value,
False), "Complete")

End Sub

Private Sub Form_Current()

Call LockBoundControls([Form], Nz(Me![tbl_MRA_Form].Form!Complete.Value,
False), "Complete")

End Sub

...but....I can't seem to unlock the form when I click on the 'Complete'
cmdbutton?

"Allen Browne" wrote:

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.

"Access User" <AccessUser@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E3B3D883-48BF-4101-BD6E-8872CBEA939B@xxxxxxxxxxxxxxxx
>
> 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?
>
> "Allen Browne" wrote:
>
>> 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.
>>
>> "chris" <chris.edwards@xxxxxxxxxxxxxxxxxx> wrote in message
>> news:86777221-0527-4231-b65f-308f8ac5cd48@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> >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?

.



Relevant Pages

  • Re: Prevent edits - unexpected effects
    ... were to click the 'Complete' checkbox on a new record w/o first having ... If the check box is true, this will lock it. ... Therefore the subform control is locked well. ... Even unbound controls ...
    (microsoft.public.access.forms)
  • Re: Prevent edits - unexpected effects
    ... If the check box is true, this will lock it. ... any edits to a record once the checkbox is selected. ... Therefore the subform control is locked well. ... Even unbound controls ...
    (microsoft.public.access.forms)
  • Re: Prevent edits - unexpected effects
    ... When you click the button to lock the form, it attempts to save the record ... Allen Browne - Microsoft MVP. ... I've had a chance to implement this code and controls onto my form ... Therefore the subform control is locked well. ...
    (microsoft.public.access.forms)
  • Re: Prevent edits - unexpected effects
    ... When you click the button to lock the form, it attempts to save the record ... Allen Browne - Microsoft MVP. ... I've had a chance to implement this code and controls onto my form ... Therefore the subform control is locked well. ...
    (microsoft.public.access.forms)
  • Re: Prevent edits - unexpected effects
    ... If the check box is true, this will lock it. ... I've had a chance to implement this code and controls onto my form and I ... any edits to a record once the checkbox is selected. ... Therefore the subform control is locked well. ...
    (microsoft.public.access.forms)