Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    27

    Unanswered: clear yes/no boxes

    Hello,
    Access 2010

    I have a form that is generated of a query. This form has yes/no boxes in it.
    When I open the form, there are boxes that are already checked off (from the last time I checked them) and I dont want there to be any already checked.

    Is there a way to make the form open up and ensure that all yes/no boxes are blank every time?

    Thanks in advance for any help.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    There's probably a more elegant way of doing this, but it's fast becoming a 20 hour day for me, and this is the best I can offer, right now. This example that will clear two Checkboxes (CB_1 and CB_2) every time the Form Loads:
    Code:
    Private Sub Form_Load()
    
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset("YourTableName")
    Do While Not rs.EOF
     rs.Edit
     rs!CB_1 = 0
     rs!CB_2 = 0
     rs.Update
     rs.MoveNext
    Loop
    
    rs.Close
    Set rs = Nothing
    Me.Requery
    
    End Sub
    You'll need to substitute the Checkbox names from the code (CB_1 and CB_2) in the example with your own names, as well as replace YourTableName with the actual name of the Table or Query the Form is based on. And you can clear more Checkboxes by simply changing this portion of the code

    rs.Edit

    rs!CB_1 = 0
    rs!CB_2 = 0

    rs.Update


    to something like this

    rs.Edit

    rs!CB_1 = 0
    rs!CB_2 = 0
    rs!CB_3 = 0
    rs!CB_4 = 0

    rs.Update


    Also be sure that the Microsoft DAO x.x. Object Library is set in references in the Form's Code Module (Tools - References) where x.x. is the particular version of the Library for your version of Access.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    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
  •