Group:  Microsoft Access ยป microsoft.public.access.gettingstarted
Thread: How to lock record in subform

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How to lock record in subform
Nova 02.08.2006 04:34:02
How can I write code to lock record in subform (continous form) by checking
one field in subform.
My mainform has 2 combo box (unbound)
My subform will show all records are linked with 2 combo box in main form
(Set linkmasterfield & childfields property on design form).
In generally, all user can edit records in subform but
in some case, I want to lock all records if field [proved] in subform is -1
(yes/no)
RE: How to lock record in subform
Ken Sheridan 02.08.2006 21:41:19
One way is to conditionally lock and disable all controls with code in the
subform's Current event procedure:

Dim ctrl As Control

On Error Resume Next
For Each ctrl In Me.Controls
ctrl.Locked = Proved
ctrl.Enabled = Not Proved
Next ctrl

If you want to lock only some controls, leaving others such as command
buttons etc available to the user then set the Tag property of those controls
you want to lock/disable to something such as 'LockMe'. You can then just
lock/disable those controls:

Dim ctrl As Control

For Each ctrl In Me.Controls
If ctrl.Tag = "LockMe" Then
ctrl.Locked = Proved
ctrl.Enabled = Not Proved
End If
Next ctrl

In the second example you don't need the error handling as you'd only tag
controls which can be locked/disabled, whereas the first tries to
lock/disable all controls and raises an error if the control type doesn't
allow this, e.g. labels.

Ken Sheridan
Stafford, England

"Nova" wrote:

[Quoted Text]
> How can I write code to lock record in subform (continous form) by checking
> one field in subform.
> My mainform has 2 combo box (unbound)
> My subform will show all records are linked with 2 combo box in main form
> (Set linkmasterfield & childfields property on design form).
> In generally, all user can edit records in subform but
> in some case, I want to lock all records if field [proved] in subform is -1
> (yes/no)

Re: How to lock record in subform
"Ron2006" <ronnemec[ at ]hotmail.com> 03.08.2006 15:13:38
Or you can do the following in the oncurrent event of the subform

if me.proved = true then
me.allowedits = false
else
me.allowedits = true
endif

or another way

me.allowedits = not me.proved



Ron


[Quoted Text]
> > How can I write code to lock record in subform (continous form) by checking
> > one field in subform.
> > My mainform has 2 combo box (unbound)
> > My subform will show all records are linked with 2 combo box in main form
> > (Set linkmasterfield & childfields property on design form).
> > In generally, all user can edit records in subform but
> > in some case, I want to lock all records if field [proved] in subform is -1
> > (yes/no)

Re: How to lock record in subform
"Ron2006" <ronnemec[ at ]hotmail.com> 03.08.2006 15:17:07
And also repeat that same code in the afterupdate event of the [proved]
field.

In both cases this is saying that once [proved] is set, no fields in
the record can be changed from this form.

Ron

Re: How to lock record in subform
Nova 11.08.2006 07:48:01


Thankyou for your help. It works

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net