Solved

Uncheck 3 checkboxes on a form if all are true

Posted on 2015-01-13
7
134 Views
Last Modified: 2015-01-14
I have this code in an onclick event of a command button on a form but it isn't working.  In a test record all three checkboxes are true.  Clicking the command button should change them to false.

    If Me.chkbxEmailList = True And Me.chkbxMailingLabel = True And Me.chkbxFaxList = True Then
        Me.chkbxEmailList = False
        Me.chkbxMailingLabel = False
        Me.chkbxFaxList = False
    End If

Open in new window


Why wouldn't this be working?

--Steve
0
Comment
Question by:SteveL13
7 Comments
 
LVL 7

Accepted Solution

by:
Robert Sherman earned 100 total points
ID: 40547910
I'd set breakpoints on lines 1 through 4, when the debugger comes up, hover over the values variables in the if line and see if they are indeed true for all 3.  Then continue the run and see if you're getting to the inside of the IF statement or if it's just skipping over.
0
 
LVL 7

Expert Comment

by:Robert Sherman
ID: 40547915
If what I mentioned above doesn't help, are those checkbox's NAME property the same as the name of the field they are bound to?   It''s been a while, but I seem to recall a possible issue around that scenario.
0
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 100 total points
ID: 40547955
If all three checkboxes are true, the code sets all three to false.  If any one of them is false, no change is made.  Is that really what you want to do?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
ID: 40548072
but it isn't working.
Can you state clearly what is meant by this? (what is, or is not happening?)

Also please state when a user can click this button, ...the form may be "dirty" at the time the button is clicked.

Also, along the lines of what Pat posted...
What is the user clicks the button by mistake...? what then,...?

To be sure, this is a curious request, ...can you take a moment to explain why this logic is needed?
perhaps there is a more efficient approach...

JeffCoachman
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 100 total points
ID: 40548435
Your code looks fine.

Try this alternative:
    If Me.chkbxEmailList And Me.chkbxMailingLabel And Me.chkbxFaxList  Then
        Me.chkbxEmailList = Not( Me.chkbxEmailList)
        Me.chkbxMailingLabel = Not(Me.chkbxMailingLabel)
        Me.chkbxFaxList = Not(Me.chkbxFaxList)
   End If

Open in new window

0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 100 total points
ID: 40548464
It should work.
Try inserting three lines for debugging and tell us what you see:

    Debug.Print "EmailList",  Me.chkbxEmailList
    Debug.Print "MailingLabel",  Me.chkbxMailingLabel
    Debug.Print "FaxList", Me.chkbxFaxList
    If Me.chkbxEmailList = True And Me.chkbxMailingLabel = True And Me.chkbxFaxList = True Then
        Me.chkbxEmailList = False
        Me.chkbxMailingLabel = False
        Me.chkbxFaxList = False
    End If

/gustav
0
 

Author Comment

by:SteveL13
ID: 40548900
What I found was code that was turning them all true again when the form was re-opened.  I'll award points to all that contributed.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now