If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Clear Checkboxes when form closes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Nov 2011
Posts: 413
DoCmd****nCommand acCmdSelectAllRecords
NameofyourCheckBox.Value = 0
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Nov 2011
Posts: 413
If your willing to upload with instructions for dummies, I will take a look at it.
Reply With Quote
  #5 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,518
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
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: Nov 2011
Posts: 413
Sheesh, I gladly bow out of this one then! Good luck!
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
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.
Reply With Quote
  #9 (permalink)  
Old
Registered User
 
Join Date: Nov 2011
Posts: 413
Or try this:

CheckBox1.Value = 0
Reply With Quote
  #10 (permalink)  
Old
Moderator
 
Join Date: Mar 2009
Posts: 5,193
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!
Reply With Quote
  #11 (permalink)  
Old
Registered User
 
Join Date: Nov 2011
Posts: 413
beats me, ask them!
Reply With Quote
  #12 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #13 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,518
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On