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
Plano TechIT SpecialistAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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
Rey Obrero (Capricorn1)Commented:
me.allowedits=me.activecheckbox 'for the main form

me.subformName.form.allowedits=me.activecheckbox  'for the subform
Plano TechIT SpecialistAuthor Commented:
hey capricorn1,
where should I put this code?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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

-Mark
Rey Obrero (Capricorn1)Commented:
what is the name of your check box?
Plano TechIT SpecialistAuthor Commented:
activecheckbox
Rey Obrero (Capricorn1)Commented:
is the check box unchecked?
Plano TechIT SpecialistAuthor Commented:
yes.
How is the "Allow Edits" property of the form supposed to be set?
Rey Obrero (Capricorn1)Commented:
allowedits is set as Yes/No or True/False
Plano TechIT SpecialistAuthor Commented:
Is the form property supposed to be set to allow edits = NO?
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
Plano TechIT SpecialistAuthor 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

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

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