VBA - Set checkbox value

See frmDatasheet

Note the big silver button in the yellow section of the form.

This button (in theory) toggles the value of the tick box.

However it toggles to a "ticked" but does not toggle back to "no tick".

QUESTION: Why won't the button toggle properly via my VBA?
WealthMan.accdb
Patrick O'DeaAsked:
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.

MacroShadowCommented:
You can use any of the following:
Me.OptOut = -1 = Me.OptOut.Value = 0

Open in new window

    If Me.OptOut = -1 Then
        Me.OptOut.Value = 0
    ElseIf Me.OptOut = 0 Then
        Me.OptOut.Value = -1
    End If

Open in new window

    If Me.OptOut = -1 Then
        Me.OptOut.Value = 0
    Else
        Me.OptOut.Value = -1
    End If

Open in new window

0
Dale FyeOwner, Developing Solutions LLCCommented:
Or

me.OptOut = NOT NZ(me.OptOut, 0)

Which will handle the situation where you inadvertently allow NULLs in a Yes/No field
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
Patrick O'DeaAuthor Commented:
Neat solution!
0
Dale FyeOwner, Developing Solutions LLCCommented:
glad to help.

I use this type of syntax a lot.  But the code that Macro posted is far more readable for either a new programmer or for someone tasked with taking over your code.
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.