Disable and Lock All Feilds wiht a check box

B

Biss

Hi I am using MS 2007 and have a form that I would like to lock = yes and
enable = No on all fields..

I would like to do this by checking a check box.. I would also like to have
the lock = no and enable = yes when I uncheck the check box..

Any ideas would be appreciated..

Many thanks in advance.

Bob
 
B

Biss

Thanks Maurice,

To tell you the truth I never new allow edits was a option, but it only
makes sense that it would be there

I would put this in the clic even or afterupdate event.

if me.chkenable then
me.allowedits=true
else
me.allowedits=false
end if

or do I have that backwards if I want to have the form read only when the
check box is checked?

Thanks again Maurice..

Bob

Que tenga buena noche.
 
M

Maurice

Biss,

Try this in the click event of the checkbox:

Private Sub Checkbox_Click()
If Me.Checkbox Then
Dim ctl As Control

For Each ctl In Me
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
ctl.Enabled = False
End If
Next
Else
For Each ctl In Me
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
ctl.Enabled = True
End If
Next
End If
End Sub

if you try to use the checkbox in combination with allowedits you'll see
that you can toggle the checkbox once and after that you cannot remove the
check anymore because edits aren't allowed.

the first option will disable the controls where the Else will enable the
controls again.

hth
 

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