469,356 Members | 2,055 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Deselect all checkboxes in Access 2007 form

Beginner seeking expert help.

I have created a split-form (Form_ChkBx)to display records in my table (MST_Table). The bottom portion of the split-form has datasheet view, the top portion has two control buttons, "Clear" & "Exit".

I would like to program the "Clear" button to loop through the form or table and deselect (clear or reset) all checkboxes.

What kind of adjustments will I need for this code?
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Dim chk As CheckBox
  3. Dim Ctl As Control
  4.  
  5. For Each Ctl In Me.Controls
  6.  
  7. If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
  8.  
  9. Next Ctl
  10.  
  11.  
  12. End Sub
Jun 13 '11 #1
9 10813
ADezii
8,800 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Dim Ctl As Control
  2.  
  3. For Each Ctl In Me.Controls
  4.   If Ctl.ControlType = acCheckBox Then Ctl = False
  5. Next Ctl
Jun 13 '11 #2
NeoPa
32,185 Expert Mod 16PB
Bob,

There seems to be a little misunderstanding here. When you say clear all the checkboxes on your form, I assume you really mean you want all the values reset to False in the recordset the form is bound to yes?

If so you need something like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdClear_Click()
  2.     With Me.Recordset
  3.         Do While Not .EOF
  4.             If !FieldName Then
  5.                 Call .Edit
  6.                 !FieldName = False
  7.                 Call .Update
  8.             End If
  9.             Call .MoveNext
  10.         Loop
  11.     End With
  12. End Sub
We don't know the names of all your fields/objects etc so you'll have to adapt it to your database.
Jun 13 '11 #3
Yes - your assumptions are correct. I would like to reset all checkbox values to false. I will let you know how it go.

Thanks Again.
Jun 13 '11 #4
Hi NoePa,

Still no success when running the code shown below. Other words, the code does not reset or clear my checkboxes. In fact, all check boex seems to be locked in the checked or unchecked position.

Right now, I'm clueless as how to regain the ability to select and deselect check boxes on the current split-form.

Any suggestion would be greately appreciated.
Otherwise I'll need to recreate a new split-form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Clear_All_Butt_Click()
  2.     With Me.Recordset
  3.         Do While Not .EOF
  4.             If !PRNT Then
  5.                 Call .Edit
  6.                 !PRNT = False
  7.                 Call .Update
  8.             End If
  9.             Call .MoveNext
  10.         Loop
  11.     End With
  12.  
  13.  
  14. End Sub
Jun 14 '11 #5
NeoPa
32,185 Expert Mod 16PB
There are many things that could conceivably go wrong with this code, but I can't see that a permanent redesign of the form is a possibility. Does it not revert to those controls being updatable if it's closed and reopened? If not, then I would assume that you have made other changes which are not related to this code.

Also, can you tell me what you see in the table itself if you look at the records after this code has run? Do they reflect what is visible on the form or are they updated as you would expect the form to be?
Jun 14 '11 #6
When I add the code tage prefix
Expand|Select|Wrap|Line Numbers
  1.  to the first line, I get a compile Error "Expected: epression". Adding the code tage subfix 
also generates a compile error.

Here is what I'm working with.
I have a simple table with four columns or fields and ten rows or records. The column headings are "ID", "PRNT", "HypLk" and "Info". The ID field show numbers 1 through 10 representing 1- records. PRNT field show one checkbox for each record. HypLk field contains a unique path location and file name (hyperlink)for each record. The Info field contains texted information related to the hyperlink attachment.

My current slpit-form is linked to my table. It has four control buttons "Print All", "Save All", "Clear All" and "Exit". All four buttons area located in the header (top screen area)with the datasheet view of my table in the bottom screen area.

I would like to program the "Clear All" button to deselect or reset all check boxes located in the "PRNT" field of the current form to the unchecked possition. Allowing the opportunity to reselect multiple check boxes for the next multiple print operation.

Thanks,
Bob
Jun 14 '11 #7
NeoPa
32,185 Expert Mod 16PB
Right. Let's handle one thing at a time. [ CODE ] tags are required for posting code in a thread. They are relevant only to posting on this site. They are not meant to be included in any code within your project.

Now I've read the rest of your post it seems to be a re-iteration (with perhaps some more detail) of what you'd already shared. It's not unhelpful, but doesn't take us forward anywhere.

The questions and requests for information in my previous post (#6) all appear to have been overlooked. I can't help you unless you respond to these.
Jun 14 '11 #8
Ok, so CODE tages are require for posting code in a thread on this site. It is my assumption that CODE tages used much like quotaion marks are used in writing; to identify the start/end of a code string?

Regarding question from post #6 - When I press the buttom to run the code, from split-form, nothing happens. No changes occured in the table. The three check boxes that were checked before running the code never changed. The only thing happened after running the code was that all check boxes locked-up. I am unable to check boxes that were previously uncheck and unable to uncheck boxes previously checked. Again running the code generated no change in the table or the form.

Thanks,
Bob
Jun 14 '11 #9
NeoPa
32,185 Expert Mod 16PB
Bob,

See [code] Tags Must be Used for more on the CODE tags. I hope that will make everything perfectly clear, but if not please let me know by PM and I will clarify.

Your second paragraph confuses me somewhat. Not because it's not pretty clear what you are saying, but because I can't imagine what may be occurring. If you'd like to attach a copy of your database for me to look at for you please go ahead (after checking out Attach Database (or other work)).
Jun 15 '11 #10

Post your reply

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

Similar topics

7 posts views Thread by Icarus | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.