Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Uncheck 3 checkboxes on a form if all are true

Posted on 2015-01-13
7
Medium Priority
?
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 39

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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 51

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

721 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