How to uncheck the check boxes in a single click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mb60
    New Member
    • Aug 2008
    • 37

    How to uncheck the check boxes in a single click

    I have hundreds of records in my database. Each has a check box. Is there any option to select or unselect all those check boxes in single click?. Please suggest.
    Thanks.
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Is this a one time thing you're looking to do or will you want to reset them on all records on a regular basis?

    Welcome to Bytes!

    Linq ;0)>

    Comment

    • mb60
      New Member
      • Aug 2008
      • 37

      #3
      The purpose of this is to select the questions from a question bank, to prepare a question paper. To generate a new one, present, I am doing it manually. Frequently I have to select or unselect the records.
      thank you

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        Ups, Ill post some code later, thought I had it here. I will find it and get back to you.

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          Use an update query for (re-)setting the field like:
          Code:
          UPDATE tblA
          SET YesNo_field =  True
          or
          UPDATE tblA
          SET YesNo_field =  False
          By using:
          Code:
          currentdb.execute ("UPDATE tblA SET YesNo_field =  False")
          in a procedure behind a button or in the OnCurrent event of a form you can do this automatically.

          Nic;o)

          Comment

          • mb60
            New Member
            • Aug 2008
            • 37

            #6
            Originally posted by nico5038
            Use an update query for (re-)setting the field like:
            Code:
            UPDATE tblA
            SET YesNo_field =  True
            or
            UPDATE tblA
            SET YesNo_field =  False
            By using:
            Code:
            currentdb.execute ("UPDATE tblA SET YesNo_field =  False")
            in a procedure behind a button or in the OnCurrent event of a form you can do this automatically.

            Nic;o)
            Sir
            Being a beginer I failed to enter the code given by you. please tell me how to enter the above code step by step.
            My db name is question bank, query name is paper settingThank you

            Comment

            • nico5038
              Recognized Expert Specialist
              • Nov 2006
              • 3080

              #7
              1) Create a form not linked to a table
              2) Create a new button and set the name to: "btnReset"
              3) Create a subform using your query "paper setting" as the recordsource
              4) Open the Events tab of the properties of the "btnReset" and double-click the "OnClick" text to get a "Procedure" text after the text.
              5) Click on the [...] button behind the "Procedure" text to go into the VBA code
              6) Enter where the cursor is located:
              Code:
              currentdb.execute ("UPDATE [paper setting] SET YesNo_fieldname =  False")
              Me.requiry
              Save the form and test.

              Btw I would never use spaces in table or query names and starting a table wit "tbl" and queries with "qry" is advisable and a lot easier in the future.
              Further you should better use the original table instead of a query to operform the UPDATE on. All needed in the above code is to replace the YesNo_fieldname with your fieldname (and preferable switch to using the table i.s.o. the query and thus change the subform's recordsource and update query to the tblName.

              Nic;o)

              Comment

              • mb60
                New Member
                • Aug 2008
                • 37

                #8
                sir
                getting error in the second line ( Me.requiry)

                Comment

                • edsuk
                  New Member
                  • Jul 2007
                  • 10

                  #9
                  Hi

                  Amend it to:

                  Me.requery

                  Comment

                  • nico5038
                    Recognized Expert Specialist
                    • Nov 2006
                    • 3080

                    #10
                    Sorry for the typo.
                    When typing the dot after Me it's enough to type "req" and press [Tab] to append the correct property.

                    Nic;o)

                    Comment

                    • mb60
                      New Member
                      • Aug 2008
                      • 37

                      #11
                      This time I got a run-time error '3061'
                      Too few parameters.Expe cted 1.

                      Comment

                      • nico5038
                        Recognized Expert Specialist
                        • Nov 2006
                        • 3080

                        #12
                        Then a field name in your UPDATE query isn't entered correctly.
                        Make sure it's the name of the field in the table/query.

                        Nic;o)

                        Comment

                        • mb60
                          New Member
                          • Aug 2008
                          • 37

                          #13
                          @nico5038
                          Dear Sir
                          A very belated (just more than a decade) thank you for your answer.
                          10 years ago I was successful in clearing the checkboxes, the same exercise helped me even today in unchecking the yes/no field in my Question bank data table.
                          Once again thanks

                          Comment

                          • nico5038
                            Recognized Expert Specialist
                            • Nov 2006
                            • 3080

                            #14
                            Dear mb60,
                            Glad to see you're still appreciating my old solution :-)
                            Nic;o)

                            Comment

                            Working...