Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Uncheck 3 checkboxes on a form if all are true

Posted on 2015-01-13
7
Medium Priority
?
159 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 400 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 40

Assisted Solution

by:PatHartman
PatHartman earned 400 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 400 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 31

Assisted Solution

by:hnasr
hnasr earned 400 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 52

Assisted Solution

by:Gustav Brock
Gustav Brock earned 400 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

916 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