Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    38

    Unanswered: Clear Yes/No Field when opening a form

    I have created a form that will allow the user to check off who they would like the report to preview. But when the form opens up again the checks are still there. How can I refresh or requery the form that will show all checkboxes clear when the form is re-opened.

    I read an article that informed me to use an update query which works but I can't seem to automate that without the prompt.

    Any help would be greatly appreciated.
    Thanks

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Is this form bound to a table? If the checkboxes are unbound they should revert back to their default values (if any) ...

  3. #3
    Join Date
    Oct 2003
    Posts
    38
    Yes, this form is bound to a query.

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Originally posted by mfernandez
    Yes, this form is bound to a query.
    Hey, I also have that same situation with a database I just created. I did use the UpdateQuery, but really hate having to click the buttons about 2-4 times. My Yes/No is based on a table and then to the query. How can you clear them out in Code? Please say exactly how to place the code to use it. I have seen something about creating functions, but not understood just how to activate the function once it is created.
    Thanks and have a nice one
    Bud

  5. #5
    Join Date
    Oct 2003
    Posts
    38
    Bud,
    Here is the code that I used and works. I got this from a friend.
    I placed this on the Forms On Open event.

    Private Sub Form_Open(Cancel As Integer)
    Dim i As Long
    Dim F As Form
    Dim RS As Recordset

    Set F = Forms![WIANotesSpecifyForm].Form
    Set RS = F.RecordsetClone

    For i = 1 To RS.RecordCount
    RS.Edit
    'On Error GoTo ErrorLockEdits
    If RS![WIANotesY/N] = -1 Then

    RS![WIANotesY/N] = 0
    RS.Update
    End If

    RS.MoveNext
    Next i


    End Sub

  6. #6
    Join Date
    Jan 2004
    Location
    Australia
    Posts
    15
    Here is an easier way using the example by mfernandez.
    Code:
    Private Sub Form_Open(Cancel As Integer)
    Dim Str as String
    
    Str = "UPDATE WIANotesSpecifyTable "
    Str = Str & "SET WIANotesSpecifyTable.[WIANotesY/N] = False "
    Str = Str & "WHERE (((WIANotesSpecifyTable.[WIANotesY/N])=True));"
    
    currentdb.Execute Str, dbFailOnError
    
    'May or may not need this.
    Me.Requery
    End Sub
    Hope this helps

Posting Permissions

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