469,273 Members | 1,624 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,273 developers. It's quick & easy.

How to uncheck the check boxes in a single click

mb60
37 32bit
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.
Jan 18 '10 #1

✓ answered by nico5038

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:
Expand|Select|Wrap|Line Numbers
  1. currentdb.execute ("UPDATE [paper setting] SET YesNo_fieldname =  False")
  2. Me.requiry
  3.  
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)

13 17898
missinglinq
3,532 Expert 2GB
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)>
Jan 18 '10 #2
mb60
37 32bit
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
Jan 18 '10 #3
TheSmileyCoder
2,321 Expert Mod 2GB
Ups, Ill post some code later, thought I had it here. I will find it and get back to you.
Jan 18 '10 #4
nico5038
3,080 Expert 2GB
Use an update query for (re-)setting the field like:
Expand|Select|Wrap|Line Numbers
  1. UPDATE tblA
  2. SET YesNo_field =  True
  3. or
  4. UPDATE tblA
  5. SET YesNo_field =  False
  6.  
By using:
Expand|Select|Wrap|Line Numbers
  1. currentdb.execute ("UPDATE tblA SET YesNo_field =  False")
  2.  
in a procedure behind a button or in the OnCurrent event of a form you can do this automatically.

Nic;o)
Jan 18 '10 #5
mb60
37 32bit
@nico5038
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
Jan 23 '10 #6
nico5038
3,080 Expert 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. currentdb.execute ("UPDATE [paper setting] SET YesNo_fieldname =  False")
  2. Me.requiry
  3.  
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)
Jan 23 '10 #7
mb60
37 32bit
sir
getting error in the second line ( Me.requiry)
Jan 23 '10 #8
edsuk
10
Hi

Amend it to:

Me.requery
Jan 23 '10 #9
nico5038
3,080 Expert 2GB
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)
Jan 23 '10 #10
mb60
37 32bit
This time I got a run-time error '3061'
Too few parameters.Expected 1.
Jan 24 '10 #11
nico5038
3,080 Expert 2GB
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)
Jan 24 '10 #12
mb60
37 32bit
@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
3 Weeks Ago #13
nico5038
3,080 Expert 2GB
Dear mb60,
Glad to see you're still appreciating my old solution :-)
Nic;o)
3 Weeks Ago #14

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by pw | last post: by
3 posts views Thread by Search & You Will Find | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.