Locking bound controls-AllenBrowne

G

Guest

Hi,

Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at steps 3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load property of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 
A

Allen Browne

Hmm. The code toggles the Locked state of the bound controls.
It won't touch controls that are not bound to a field.
Command buttons are not bound to a field.

The Exception List refers to bound controls that you *don't* want it to
change the Locked state of, i.e. controls that would normally be toggled,
but you want them left alone. Add to the exception list won't help with
unbound controls.

Command buttons don't have a Locked property.
But it's easy enough to add a line for each one to toggle their Enabled
property:
Me.cmdInvDate.Enabled = Not bLock
 
G

Guest

Is there wayto lock butons onLoad? it not set on EventProcdure only
=LockBoundControls([Form],True) so I dont knowhow add more code.
thank you.
--
k3geyer


Allen Browne said:
Hmm. The code toggles the Locked state of the bound controls.
It won't touch controls that are not bound to a field.
Command buttons are not bound to a field.

The Exception List refers to bound controls that you *don't* want it to
change the Locked state of, i.e. controls that would normally be toggled,
but you want them left alone. Add to the exception list won't help with
unbound controls.

Command buttons don't have a Locked property.
But it's easy enough to add a line for each one to toggle their Enabled
property:
Me.cmdInvDate.Enabled = Not bLock

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

k3geyer said:
Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just
normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at steps
3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load property of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 
G

Guest

Working to take buttons outof here
Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl, acPage,
acPageBreak, acImage, acObjectFrame
'Do nothing

But add Close buttoin toExecptin list?
 
A

Allen Browne

Your options are to modify the code so that it handles your buttons
(specific buttons? on every form? only some buttons? all buttons?), or to
use an Event Procecure as shown.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

k3geyer said:
Is there wayto lock butons onLoad? it not set on EventProcdure only
=LockBoundControls([Form],True) so I dont knowhow add more code.
thank you.
--
k3geyer


Allen Browne said:
Hmm. The code toggles the Locked state of the bound controls.
It won't touch controls that are not bound to a field.
Command buttons are not bound to a field.

The Exception List refers to bound controls that you *don't* want it to
change the Locked state of, i.e. controls that would normally be toggled,
but you want them left alone. Add to the exception list won't help with
unbound controls.

Command buttons don't have a Locked property.
But it's easy enough to add a line for each one to toggle their Enabled
property:
Me.cmdInvDate.Enabled = Not bLock

k3geyer said:
Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and
mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just
normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at
steps
3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load property
of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 
G

Guest

OK,I changeto dblclick datefeilds and no clendar buttonsmore.But why my
subfrom combos allways stays locked?I click Lock button all mainform
unlock.all subfom still lock.I delet all code an copypaste again,same problem.
thankyou.
--
k3geyer


Allen Browne said:
Your options are to modify the code so that it handles your buttons
(specific buttons? on every form? only some buttons? all buttons?), or to
use an Event Procecure as shown.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

k3geyer said:
Is there wayto lock butons onLoad? it not set on EventProcdure only
=LockBoundControls([Form],True) so I dont knowhow add more code.
thank you.
--
k3geyer


Allen Browne said:
Hmm. The code toggles the Locked state of the bound controls.
It won't touch controls that are not bound to a field.
Command buttons are not bound to a field.

The Exception List refers to bound controls that you *don't* want it to
change the Locked state of, i.e. controls that would normally be toggled,
but you want them left alone. Add to the exception list won't help with
unbound controls.

Command buttons don't have a Locked property.
But it's easy enough to add a line for each one to toggle their Enabled
property:
Me.cmdInvDate.Enabled = Not bLock


Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and
mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just
normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at
steps
3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load property
of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 
A

Allen Browne

Until you get this debugged, temporarily comment out the error handler by
adding a single quote to the start of the 2nd line, i.e.:
'On Error GoTo Err_Handler

Now when it fails, you can see which line is giving the error, and what it
is trying to do at that point. Use the Immeidate Window (Ctrl+G) to ask
Access what's going on, e.g.:
? ctl.Name

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

k3geyer said:
OK,I changeto dblclick datefeilds and no clendar buttonsmore.But why my
subfrom combos allways stays locked?I click Lock button all mainform
unlock.all subfom still lock.I delet all code an copypaste again,same
problem.
thankyou.
--
k3geyer


Allen Browne said:
Your options are to modify the code so that it handles your buttons
(specific buttons? on every form? only some buttons? all buttons?), or to
use an Event Procecure as shown.

k3geyer said:
Is there wayto lock butons onLoad? it not set on EventProcdure only
=LockBoundControls([Form],True) so I dont knowhow add more code.
thank you.
--
k3geyer


:

Hmm. The code toggles the Locked state of the bound controls.
It won't touch controls that are not bound to a field.
Command buttons are not bound to a field.

The Exception List refers to bound controls that you *don't* want it
to
change the Locked state of, i.e. controls that would normally be
toggled,
but you want them left alone. Add to the exception list won't help
with
unbound controls.

Command buttons don't have a Locked property.
But it's easy enough to add a line for each one to toggle their
Enabled
property:
Me.cmdInvDate.Enabled = Not bLock


Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and
mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just
normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at
steps
3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load
property
of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 
G

Guest

thanks chesewhiz thats the thing but ihad to do it likeAllens code
Me.cmdInvDate.Enabled = Not bLock
or it don't togle like its spost too. Thank you.

--
k3geyer


Cheese_whiz said:
Use the "enabled" property instead of the locked property with the calendar
button. Works for me, anyway.

CW

k3geyer said:
Working to take buttons outof here
Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl, acPage,
acPageBreak, acImage, acObjectFrame
'Do nothing

But add Close buttoin toExecptin list?

--
k3geyer


k3geyer said:
Hi,

Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at steps 3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load property of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 
G

Guest

1.Th problemwas ihave other captin on the button "Lock" and it fight with
yourcode.Work super now.I woudnt found that code

Me.cmdInvDate.Enabled = Not bLock

in milion years thankyou thank you!!

2.Itry lots of way to Lock whenSave but always error "Youcant disable a
control while it has the focus" (calendarbuttins insubform). I try lotsof
way to setfocus otherplace everytime calendar buttins use but same eror.Now i
only make form user haveto close,no navgiaton buttns no nothing only1 record
show.Work good also,Im very happy.I relly apprceate your greatideas &help
Allen!!
--
k3geyer


Allen Browne said:
Hmm. The code toggles the Locked state of the bound controls.
It won't touch controls that are not bound to a field.
Command buttons are not bound to a field.

The Exception List refers to bound controls that you *don't* want it to
change the Locked state of, i.e. controls that would normally be toggled,
but you want them left alone. Add to the exception list won't help with
unbound controls.

Command buttons don't have a Locked property.
But it's easy enough to add a line for each one to toggle their Enabled
property:
Me.cmdInvDate.Enabled = Not bLock

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

k3geyer said:
Im tryingto use his linlk: http://allenbrowne.com/ser-56.html and mostly
worksgreat.anybody know whycalnedar buttons dont lock?They just
normalbuttons
and i added ecxeptin list like so

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock, "cmdInvDate")
End Sub

the insrtuction says
(Optional) Add the names of any controls you do not want unlocked at steps
3
and 4.
but 3 isthe red rctalngle & 4 is

To initialize the form so it comes up locked, set the On Load property of
your form to:
=LockBoundControls([Form],True)
I dontknow what idid wrong.thank you.
 

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

Top