Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772

    RecordsetClone object can be referenced and manipulated as shown in my code sample.
    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.

  2. #17
    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
    Using June7's method, which is better because, as he said, it covers all RecordSets, even if it's a Filtered RecordSet:

    To tick all
    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

    To untick all

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

    To do both with a single button

    • Create a Command Button
    • Name it cmdTickUntickAllBoxes
    • Set it's Caption to Tick All

    Code:
    Private Sub cmdTickUntickAllBoxes_Click()
    
    Dim rs As DAO.Recordset
     
    Set rs = Me.RecordsetClone
    
    If cmdTickUntickAllBoxes.Caption = "Tick All" Then
      
     cmdTickUntickAllBoxes.Caption = "Untick All"
     
     With rs
     
     .MoveFirst
     
     Do While Not rs.EOF
      .Edit
      !CheckboxFieldName = -1
      .Update
      .MoveNext
     Loop
    
    End With
    
    rs.Close
    
    Set rs = Nothing
    
    Me.Requery
    
    Else
    
     cmdTickUntickAllBoxes.Caption = "Tick All"
     
     With rs
     
     .MoveFirst
     
     Do While Not rs.EOF
      .Edit
      !CheckboxFieldName = 0
      .Update
      .MoveNext
     Loop
    
    End With
    
    rs.Close
    
    Set rs = Nothing
    
    Me.Requery
    
    End If
    
    End Sub

    Linq ;0)>

  3. #18
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    I renamed an existing command button and changed the caption, copied the third example over the VBA code already there after changing CheckboxFieldName to Profiles. Clicked and nothing happened. Should I see check marks?

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    If you renamed the button did you rename the procedure in the Sub line?

    Always more than one way to accomplish same result. Another option to tick/untick all:

    CurrentDb.Execute "UPDATE tablename Set Profiles=" & IIf(Me.cmdTickUntickAllBoxes.Caption = "Tick All", True, False)
    Me.cmdTickUntickAllBoxes.Caption = IIf(Me.cmdTickUntickAllBoxes.Caption = "Tick All", "Untick All", "Tick All")
    Last edited by June7; 06-20-2014 at 08:21 PM.
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multi Select Check Boxes?
    By CDavis10 in forum Forms
    Replies: 2
    Last Post: 07-19-2013, 07:04 AM
  2. Check Boxes On Form
    By Iain in forum Forms
    Replies: 14
    Last Post: 06-09-2012, 12:09 PM
  3. Check my Select Statement in Form
    By OMGsh Y did I say Yes in forum Forms
    Replies: 12
    Last Post: 12-07-2010, 02:13 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