How lock all fields on a form EXCEPT one field if certain criteria exists

I need to be able to lock all fields on a form if certain criteria exists.

Something like this in the onopen event of the form: (which of course isn't even close)

If me.cboStatus = 1 then
Me.locked except me.cboStatus
endif
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
Then you will have to note all the types of control you will be locking.
textboxex, comboboxes, ...etc...

Not all controls can be locked, ...so you cant just loop all of them

In any event...
Code would be roughly something like this:

Dim ctl As Control

If Me.cboStatus = 1 Then
    For Each ctl In Me
        If (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox) Then
            If ctl.Name <> "cboStatus" Then
                'MsgBox ctl.Name
                ctl.Locked = True
            End If
        End If
    Next ctl
Else
    For Each ctl In Me
        If (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox) Then
            If ctl.Name <> "cboStatus" Then
                'MsgBox ctl.Name
                ctl.Locked = False
            End If
        End If
    Next ctl

End If



JeffCoachman
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
The code above would go on the current event...
0
EirmanChief Operations ManagerCommented:
Not exactly what you requested but worth considering ....
if you want manual control of field locking have a look my solution here
http://www.experts-exchange.com/Database/MS_Access/Q_28374881.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.