Solved

Uncheck 3 checkboxes on a form if all are true

Posted on 2015-01-13
7
143 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 36

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

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…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

830 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