Lock form when check box is checked.

This is a database of company vehicles. As they expire, we get rid of them.
On the entry form I have placed a yes /no checkbox thats labled "Active"
When this box is unchecked, I do not want to be able to edit the current record.
It would be great if I could "grey out" the record also.
vehicles.jpg
LVL 7
mmarisAsked:
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.

Rey Obrero (Capricorn1)Commented:
try

me.allowedits=me.activecheckbox
0
Rey Obrero (Capricorn1)Commented:
me.allowedits=me.activecheckbox 'for the main form

me.subformName.form.allowedits=me.activecheckbox  'for the subform
0
mmarisAuthor Commented:
hey capricorn1,
where should I put this code?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Rey Obrero (Capricorn1)Commented:
in the afterupdate event of the check box
0
mmarisAuthor Commented:
Private Sub activecheckbox_AfterUpdate()
Me.AllowEdits = Me.activecheckbox
End Sub
It still alows me to make changes to the record.

-Mark
0
Rey Obrero (Capricorn1)Commented:
what is the name of your check box?
0
mmarisAuthor Commented:
activecheckbox
0
Rey Obrero (Capricorn1)Commented:
is the check box unchecked?
0
mmarisAuthor Commented:
yes.
How is the "Allow Edits" property of the form supposed to be set?
0
Rey Obrero (Capricorn1)Commented:
allowedits is set as Yes/No or True/False
0
mmarisAuthor Commented:
Is the form property supposed to be set to allow edits = NO?
0
Rey Obrero (Capricorn1)Commented:
Is the form property supposed to be set to allow edits = NO?

this depend on how you want to use your form, normally this is set to YES in design view of the form.

you can toggle this property to either Yes or No using VBA codes at runtime
0
mmarisAuthor Commented:
Capricorn1,
thanks for your help, but here is the code I was looking for:

Private Sub Form_Current()
If Me.activecheckbox = False Then
Me.AllowEdits = False
Me.frmsubStatementInvoice.Form.AllowEdits = False
Else
Me.AllowEdits = True
Me.frmsubStatementInvoice.Form.AllowEdits = True
End If
End Sub

Private Sub Form_Load()
Me.Requery
End Sub
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
Rey Obrero (Capricorn1)Commented:
a simpler version

Private Sub Form_Current()

Me.AllowEdits = Me.activecheckbox
Me.frmsubStatementInvoice.Form.AllowEdits = Me.activecheckbox

End Sub

just like what i posted above

and i don't think you need this

Private Sub Form_Load()
Me.Requery
End Sub

a form will always do that when loading

0
Rey Obrero (Capricorn1)Commented:
see my post at http:#a30731110
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.