Locking controls at runtime

  • Thread starter Thread starter James D Carroll
  • Start date Start date
J

James D Carroll

I have a gui with several forms and subforms. I'd like to lock and unlock
certain controls at runtime, but for some reason, though I don't get an
error, the controls are not doing what I tell them to. All of them are
bound if that matters. The following code DOES work:

sub setAll(locked as boolean)
'this is so that controls that don't have a locked property don't cause
a probem
on error resume next

dim f as variant
dim c as variant

for each f in forms
for each c in f
c.locked = locked
next c
next f
end sub

It works fine whether I pass True or False, but when I try something like
the following:

sub lockGroup()
with Form_frmTest
.txtCtl1.locked = false
.txtCtr2.locked = false
.Repaint
end with
end sub

That code doesn't work. I call the .Repaint to in the hopes that maybe
Access wasn't updating the GUI right away, but it didn't help.

Thanks for any ideas,

PS: Access 97 w/ no SP's running on NT4 SP6
 
It works fine whether I pass True or False, but when I try something like
the following:

sub lockGroup()
with Form_frmTest
.txtCtl1.locked = false
.txtCtr2.locked = false
.Repaint
end with
end sub

That code doesn't work. I call the .Repaint to in the hopes that maybe
Access wasn't updating the GUI right away, but it didn't help.

Your form reference is wrong:

Sub lockGroup()
With Me
.txtCtl1.Locked = False
.txtCtl2.Locked = True
End With
End Sub

Works just fine.

Now, before I let you go I feel compelled to warn you that you ***must***
install both service packs for A97 if you do not want to lose or corrupt
data. No exceptions! If you think I'm kidding you, look up the Bookmark bug
in the Knowledge Base.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top