Form Lock/Unlock

D

d9pierce

Hi,

I have different forms that I want to add a bound chkbox(Record_Lock),
to my forms and I want to be able to check / Uncheck to enable/disable
all fields, combo, and listbox's with this control by its click
function with out locking this check box. The basic function is to
prevent accidential changes, you have to ckick this to be able to edit
fields...! I would also like to keep the back color of the controls
white, and change the forecolor to green when unlocked, and blue when
locked.

Could anyone help out iwth this. I found similiar things but nothing
that I could convert to this function.

Thanks,

Dave

d9pierce at mchsi dot com
 
M

Marshall Barton

I have different forms that I want to add a bound chkbox(Record_Lock),
to my forms and I want to be able to check / Uncheck to enable/disable
all fields, combo, and listbox's with this control by its click
function with out locking this check box. The basic function is to
prevent accidential changes, you have to ckick this to be able to edit
fields...! I would also like to keep the back color of the controls
white, and change the forecolor to green when unlocked, and blue when
locked.


Since you need to selectively lock controls, you need a way
to identify the ones that you do want to lock. This is
easily done by setting those control's Tag property to
something like LOCK. Then you can use a simple code loop to
manage the locking:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "LOCK" Then
If Record_Lock = True Then
ctl.Locked = True
ctl.Forecolor = vbBlue
Else
ctl.Locked = False
ctl.Forecolor = vbGreen
End If
End If
Next ctl
 

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