Results 1 to 8 of 8
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Check all check boxes on continuous form

    I'm using a filtered continuous form to show all records where a check box has not been checked. I added a command button in the form header as an option for the user to change the value of all check boxes to -1, but it only changes the record that has the focus. How can I get the button to check all of the boxes on the form with a single click?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    An unbound control within a continuous from will only be associated with the record that has the focus. Instead, use a bound checkbox control. Create a new field of type Boolean in your table and bind a control to that new field.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    An UNBOUND control will show the same value for ALL records unless it has a dynamic calculation as ControlSource.

    If checkbox is BOUND to a table field, setting the checkbox for ALL records requires either:

    1. looping code to set focus to each record and change field value

    2. SQL UPDATE action to change value of records in table then refresh the form to display the table update
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Just loop through the Recordset and set the Checkbox:

    Code:
    Private Sub cmdTickAllBoxes_Click()
    
    Dim rs As DAO.Recordset
    
    Set rs = Me.RecordsetClone
    
     With rs
     
      .MoveFirst
     
     Do While Not rs.EOF
      .Edit
      !CheckboxFieldName = -1
      .Update
      .MoveNext
     Loop
    
    End With
    
    rs.Close
    
    Set rs = Nothing
    
    Me.Requery
    
    End Sub

    This covers all RecordSets, even if it's filtered, and, if I remember correctly, I believe I archived it from a response to a post that June7 made a year or so ago!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes, RecordsetClone is one way to loop through a form's records. Don't even have to declare and set object variable.

    With Me.RecordsetClone
    .MoveFirst
    Do While Not .EOF
    .Edit
    !CheckboxFieldName = True
    .Update
    .MoveNext
    Loop
    End With
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Thank you for the code. I figured it would use a loop, but I couldn't get it working on my own. I was using the name of the checkbox on the form instead of the name of its control source from the query. This is changing the checkbox value for every record in the table, like you said it would. The query is filtered to only show start dates within the last week, and that is what is displayed on the form. How can I get it to only change the filtered records that are on the form/query?

  7. #7
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    In my endless search of the forum to find answers to my ignorance, I solved the problem.
    Replaced "Set rs = Me.RecordsetClone"
    with "Set rs = CurrentDb.OpenRecordset("qryApprove")"
    Thank you all for pointing me in the right direction.

  8. #8
    Jayro is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    3
    This is exactly what I'm looking for but I don't know how to pull it off. I have a query that identifies un-reviewed items in a table (Reviewed = False). I am pulling those items into a "Multiple Items" (continuous?) form called frm_MilitaryCheck. The form has 3 fields
    1) Military Y/N (Checkbox),
    2) Business Name (Text) and
    3) Reviewed Y/N (Checkbox).
    For all records in this form, the Military Checkbox is visible and false (unchecked), the Business Name is displayed (read only) and Reviewed Checkbox is not visible and FALSE (unchecked).
    Users are told to Review the Business name, and if its Military, Click in the Checkbox. Once the records are viewed, They click a Reviewed button which closes the form. (BTW - I have an update query that runs After import and updates Exact Matches with Military = True and Reviewed = True. The records in this query based form are fallout due to typos, unofficial acronyms, etc.)
    So now, when the data is Loaded or Unloaded, I want the Reviewed Checkbox value set to TRUE. How do I do that? I don't use Access often enough to know more that the basics. I think I'll be highlighting the FORM and adding an "On Unload" event but I don't know what to do from there.
    Here are the object names:
    qry_LikeMilitary - Queries data where the Reviewed field is blank (false). Runs after exact matches are reviewed in an update query.
    frm_MilitaryCheck - Pulls in the Military, BusinessName and MilCheck fields for all query results.
    Military Checkbox - chk_Military
    Business Name - txt_BusinessName
    Reviewed Checkbox - chk_MilCheck (Hidden)
    Using Access 2013,
    Thanks for your Step by Step response!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Check box based on values of other check boxes?
    By Michael.Reynolds1775 in forum Forms
    Replies: 3
    Last Post: 03-25-2015, 12:58 AM
  2. Replies: 18
    Last Post: 06-20-2014, 12:13 PM
  3. Check Boxes On Form
    By Iain in forum Forms
    Replies: 14
    Last Post: 06-09-2012, 12:09 PM
  4. Filter by Form: Check Boxes.
    By tbh7x in forum Forms
    Replies: 0
    Last Post: 08-18-2010, 09:15 AM
  5. To check or Un-Check all Boxes in a form
    By devcon in forum Forms
    Replies: 7
    Last Post: 05-01-2010, 12:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums