How can I force a yes/no box to become checked if I check another one?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mmmel
    New Member
    • Feb 2010
    • 52

    #1

    How can I force a yes/no box to become checked if I check another one?

    Hello! (MS Access 2007 form)

    I have three yes/no (check box) fields for registration:
    1. Full year (Sept-May)
    2. 1st term (Sept-Dec)
    3. 2nd term (Jan-May)

    Of course, if they register and pay for the full year, I would like the 1st term and second term check boxes to automatically check themselves off. If they don't, I want to be able to check one or the other or both.

    I've tried using an iff:

    =IIf([Full Year]=True,-1,0)

    but I'm not sure where to put it. If I put it into the Control Source, I lose the ability to check the 1st term or second term box by itself, and also it ceases to be stored with the person (which is important).

    I'm sure it's exceedingly simple...any ideas out there?
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Put your code in the afterupdate event of the checkbox that controls the other checkbox(es). That way, as soon as that control is updated and you leave the control (tab to the next control) the code is executed.

    Jim

    Comment

    • Mmmel
      New Member
      • Feb 2010
      • 52

      #3
      Thanks! Tried putting this into the afterupdate:

      =IIf([Full Year]=-1,[1st semester]=-1,[1st semester]=0)

      I've tried using True, False, Yes, No, everything. Nothing happens. I also tried putting it into the Beforeupdate of the 1st semester box. Nothing happened then either! I'd just be happy if SOMETHING happened, so I could debug!

      Sorry to be such a noob...could you dumb it down for me even more? THANKS! : )

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        :) Yes, I understand your frustration. It should be
        Code:
        if me![Full Year] = -1 then
            me![1st Semester] = -1
            me![2nd Semester] = -1
        else
        
            me![1st Semester] = 0
            me![2nd Semester] = 0
        endif
        I'm not so sure about the wisdom of the =0s in the Else, but perhaps that is logically correct for you.

        Jim

        Comment

        • Mmmel
          New Member
          • Feb 2010
          • 52

          #5
          Jim, you ROCK!

          THANK YOU! THANK YOU! THANK YOU! You're right - there is NO wisdom to putting =0 in the Else. I omitted it. Works perfectly now!

          I had just never worked with if's in the Code Builder before, only iif's in the expression builder. Big difference!

          Thanks again! I so appreciate it!

          Melody

          Comment

          • OldBirdman
            Contributor
            • Mar 2007
            • 675

            #6
            I'm not sure I agree with the setup here. Unless there is absolutely no difference between registering for 1st term, then later registering for 2nd term and with registering for both at the same time, I would make these RadioButtons with 1st, 2nd, Both. Only one could be chosen.
            If you proceed as you are though, then the code should be:
            Code:
            me![1st Semester] = me![Full Year] 
            me![2nd Semester] = me![Full Year]
            This would correctly allow [Full Year] to be unchecked, and each semister would be unchecked also.

            Comment

            • Mmmel
              New Member
              • Feb 2010
              • 52

              #7
              Thanks for the feedback! There actually is quite a big difference. If you decide to register for the full year at the outset, you get a cheaper rate. Many members choose to only register in the fall, and then choose (or not) to register again in the winter. In this case, they would have 1st Semester checked, and 2nd Semester Checked, but not Full Year. They end up paying more since they've paid in two installments, if you like. I key my Member Info sheets off of the 1st Semester and 2nd Semester checkboxes, so that I have different lists for each semester, so it is important to track them separately. But, now that it will automagically check 1st Semester and 2nd Semester when I check Full Year, this makes it no more work at all!

              I've gone back and forth with just having an "Active Member" checkbox to key my reports off of, but then I can't go back and print out Member Info sheets from last fall, which I'd like to do.

              This was my very first database, and one thing I learned is to plan it out well at the outset! (which I probably didn't do as well as I could!). Ahhhh...the old learning curve!

              Comment

              • jimatqsi
                Moderator Top Contributor
                • Oct 2006
                • 1293

                #8
                Melody,
                You're in for a lot of fun. The "code builder" is where the action is. I've been programming in Access for 10 years and I learn something nearly every day from posts on bytes.com, so stick around. Read random threads for 15 minutes a day, you'll be surprised how quickly it sinks in.

                Jim

                Comment

                • Mmmel
                  New Member
                  • Feb 2010
                  • 52

                  #9
                  Originally posted by jimatqsi
                  Melody,
                  You're in for a lot of fun. The "code builder" is where the action is. I've been programming in Access for 10 years and I learn something nearly every day from posts on bytes.com, so stick around. Read random threads for 15 minutes a day, you'll be surprised how quickly it sinks in.

                  Jim
                  What a great idea! I've just been bopping around here trying to figure out why Access throws a fit when I import a text file ("Subscript Out of Range"). It all looks so good! Back to the search...

                  Comment

                  • jimatqsi
                    Moderator Top Contributor
                    • Oct 2006
                    • 1293

                    #10
                    Originally posted by Mmmel
                    What a great idea! I've just been bopping around here trying to figure out why Access throws a fit when I import a text file ("Subscript Out of Range"). It all looks so good! Back to the search...
                    You might try Google's advanced search page and specify to search only domain bytes.com. I find that often works better than using the site's search function.

                    Importing text is usually pretty easy to get it done. Try importing only one column, then add another and another, that might narrow it down some.

                    Jim

                    Comment

                    • Mmmel
                      New Member
                      • Feb 2010
                      • 52

                      #11
                      Thanks, Jim! I eventually just gave up and typed in the info (only for four people), but I will work on solving this one.

                      Cheers!

                      : )

                      Comment

                      • jimatqsi
                        Moderator Top Contributor
                        • Oct 2006
                        • 1293

                        #12
                        Melody, I want you to see this thread


                        just to make the point about the value of a few minutes "bopping around" at Bytes.

                        Jim

                        Comment

                        Working...