Solved

Uncheck 3 checkboxes on a form if all are true

Posted on 2015-01-13
7
137 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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

21 Experts available now in Live!

Get 1:1 Help Now