Results 1 to 4 of 4
  1. #1
    Ayiramala is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2014
    Location
    Kerala, India
    Posts
    74

    Unchecking all check boxes on exit

    Hi,
    I wanted to uncheck all check boxes on a form on exit. I added the following to the ON EXIT event of the form. It works, but takes a lot of time to finish. there are close to 700 records on this table:

    Dim rs As DAO.Recordset

    Set rs = Me.RecordsetClone


    With rs
    .MoveFirst

    Do While Not rs.EOF
    .Edit


    !SELECT = 0
    .Update
    .MoveNext
    Loop

    End With

    rs.Close

    Set rs = Nothing

    Me.Requery


    End Sub

    'SELECT' is the name of the check box. Is the code correct? If not, could you correct it?
    Thanks.

  2. #2
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    I'm not really sure about the coding, but I do have a nice alternative:

    I have something similar in my database, although, I just created an update query that selects all records checked "yes" and updates to "no." I think I use the On Close event to run the macro, just get rid of the warning popups in the macro! Hope that helps.

  3. #3
    Ayiramala is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2014
    Location
    Kerala, India
    Posts
    74
    Quote Originally Posted by cbende2 View Post
    I'm not really sure about the coding, but I do have a nice alternative:

    I have something similar in my database, although, I just created an update query that selects all records checked "yes" and updates to "no." I think I use the On Close event to run the macro, just get rid of the warning popups in the macro! Hope that helps.
    Thanks. That'll do exactly what I want to do. But the problem is, how do we remove those popups? Did a bit of a search and found someone's suggestion to use
    DoCmd.SetWarnings False 'Turn off warnings
    and later
    DoCmd.SetWarnings True 'Turn warnings back

    But how and where do we use them?


  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Don't have to bother with SetWarnings in VBA code:

    CurrentDb.Execute "UPDATE tablename SET fieldname = False"
    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.

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

Similar Threads

  1. Replies: 18
    Last Post: 06-20-2014, 12:13 PM
  2. Replies: 2
    Last Post: 12-20-2012, 03:06 PM
  3. Replies: 6
    Last Post: 11-04-2012, 02:28 PM
  4. Check Boxes
    By jordanturner in forum Access
    Replies: 1
    Last Post: 10-01-2010, 09:29 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