Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2012
    Posts
    13

    Clear Checkboxes when form closes

    I'm diligently trying to relearn Access after a 10 year hiatus. So you may see me a lot.

    I have an attendance form that is filled out weekly that will update in my table for with correct date. I have 2 details that I would like to solve. The first is that when I check off who was in attendance and update my table, I am unable to clear the checkboxes so that I can start from scratch with my attendance. I would like a button to clear them.

    The other issue I am having is my Refresh/RunQuery button in the same form. I use this button to update my table. The problem is that when if I push the button before I'm done, I will have duplicates for every time I push the button. I have set up a Look for duplicate Records query, but I am wondering if this is the easiest way.

    Thanks. Caryn

  2. #2
    Join Date
    Nov 2011
    Posts
    413
    DoCmd****nCommand acCmdSelectAllRecords
    NameofyourCheckBox.Value = 0

  3. #3
    Join Date
    Oct 2012
    Posts
    13
    I couldn't get that to work. I tried it on the form open and in a button. My checkbox is called TempAttendance.

  4. #4
    Join Date
    Nov 2011
    Posts
    413
    If your willing to upload with instructions for dummies, I will take a look at it.

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,574
    Quote Originally Posted by mnyrac View Post

    ...when I check off who was in attendance and update my table, I am unable to clear the checkboxes ...I would like a button to clear them...
    Burrina's code won't do this; this will, placed in the OnClick event of your aforementioned Command Button:
    Code:
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
      
      Set db = CurrentDb
      
      Set rs = db.OpenRecordset("Table/QueryName")
    
      Do While Not rs.EOF
       
       rs.Edit
    
       rs!TempAttendance = 0
    
       rs.Update
       
      rs.MoveNext
    
      Loop
    
      rs.Close
      
      Set rs = Nothing
      
      Me.Requery

    You'll need to replace Table/QueryName with the actual name of your Form's RecordSource.

    Linq ;0)>
    Hope this helps!

    The Devil's in the Details!!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Nov 2011
    Posts
    413
    Sheesh, I gladly bow out of this one then! Good luck!

  7. #7
    Join Date
    Oct 2012
    Posts
    13
    I'm not sure what I am doing wrong, but here is the code that I used. I still couldn't get it to work. The question I have is: tblINDIVIDUALS is a linked table from another database; I have a query that organizes the names in alphabetical order and that query (queryINDIVIDUALS) is what is used to create the form. I tried using both the table and the query and neither worked.

    Private Sub Clear_Click()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Set db = CurrentDb

    Set rs = db.OpenRecordset("tblINDIVDUALS")

    Do While Not rs.EOF

    rs.Edit

    rs!TempAttendance = 0

    rs.Update

    rs.MoveNext

    Loop

    rs.Close

    Set rs = Nothing

    Me.Requery

    End Sub

  8. #8
    Join Date
    Nov 2011
    Posts
    413
    onclick="if(this.checked){checkAll(document.myform .list)}else{clearAll(document.myform.list)}"
    See if that works for you.

  9. #9
    Join Date
    Nov 2011
    Posts
    413
    Or try this:

    CheckBox1.Value = 0

  10. #10
    Join Date
    Mar 2009
    Posts
    5,287
    Why not:
    Code:
    Const c_SQL As String = "UPDATE tblINDIVDUALS SET TempAttendance = 0;"
    CurrentDb.Execute c_SQL, dbFailOnError + dbSeeChanges
    Me.Requery
    Have a nice day!

  11. #11
    Join Date
    Nov 2011
    Posts
    413
    beats me, ask them!

  12. #12
    Join Date
    Oct 2012
    Posts
    13
    Ok I got MissingLing's code to work! Thanks a bunch!

    FYI - I had spelled Attendance wrong and that's what was throwing everything off. Duh!

    Caryn

  13. #13
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,574
    As my signature says, 'The Devil's in the Details!'

    Glad we could help!

    Linq ;0)>
    Hope this helps!

    The Devil's in the Details!!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •