Results 1 to 11 of 11
  1. #1
    kloun04 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Wisconsin
    Posts
    33

    Post Clear all ChecktBoxes on Form with Cmd

    I have a form called Frm: Mtg Attendance Data Entry that appends to AttendanceAppendTable. On my form I have three Yes/No Check Box options of "Attended Meeting", "Guest", and "Presenter". The Control Names are "TempAttendance", "Guest", and "Presenter" respectively. The append works just fine, however, when I return to Frm: Mtg Attendance Data Entry form the Check Boxes are still selected and I need them to be blank so that I can start over for my next append. I have tried several different variations of codes I have found online but haven't gotten anything to work. Below are a couple codes I tried modifying, but they don't work...obviously. Can someone please help with my code? I just want to be able to click on the command button and make all the text boxes Null. Thanks.



    Private Sub ClearFormText(frm As Form)
    Dim ctl As Control
    Dim CheckBox As CheckBox
    For Each ctl In frm.Controls
    If ctl.ControlType = CheckBox Then
    Set CheckBox = ctl
    If CheckBox.Tag = "True" Then
    CheckBox.Value = "False"
    End If
    End If
    Next ctl
    End Sub

    --------

    Private Sub ClearBoxes(frm As Form)
    Dim ctlVar As Control
    For Each ctlVar In Me.Controls
    If ctlVar.ControlType = CheckBox Then
    If CheckBox.Value = Is Not Null Then
    CheckBox.Value = Null
    End If
    End If
    End Sub

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Just do it directly:
    Code:
    Private Sub ClearBoxes()
        Me.TempAttendance = False
        Me.Guest = False
        Me.Presenter = False
    end sub
    I just want to be able to click on the command button and make all the text boxes Null.
    I just read your post again and noticed Text Boxes? Not Check Boxes?
    Last edited by davegri; 07-24-2018 at 02:52 PM. Reason: rev

  3. #3
    kloun04 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Wisconsin
    Posts
    33
    They are check boxes. I tried the above code and it didn't work.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Why not a subform bound to table and controls bound to fields? Move to new record row for data input.

    What does "didn't work" mean - error message, wrong results, nothing happens?
    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.

  5. #5
    kloun04 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Wisconsin
    Posts
    33
    I don't want a subform because every time i need to update who attended the meeting i have to search for the correct record, which is cumbersome. if i just typed in their names into a field i would have data integrity issues. It's easier for me to just run down the row of people's names and select who attended, who attended as a guest and who attended as a presenter.

    For "didn't work", i mean nothing happened.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    So these checkboxes are bound to fields? If you need to set all records then run UPDATE sql.

    CurrentDb.Execute "UPDATE table SET ...."
    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.

  7. #7
    kloun04 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Wisconsin
    Posts
    33
    June7 I am a NOVICE, i don't know what you mean.
    Is there anyone else who can help or provide more information in "simple" terms?

  8. #8
    kloun04 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Wisconsin
    Posts
    33
    I tried this, but it only clears the first line of the form, whereas I need all of them cleared.

    Private Sub Command47_Click()
    If Me.TempAttendance = True Then
    Me.TempAttendance.Value = False
    End If


    If Me.Guest = True Then
    Me.Guest.Value = False
    End If


    If Me.Presenter = True Then
    Me.Presenter.Value = False
    End If


    End Sub

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Quite possibly. We are volunteers. People answer what they want to answer. I am doing the best I can with the info provided and frankly, my suggestion is simple terms. I can take a look at your db tonight.

    Private Sub Command47_Click()
    CurrentDb.Execute "UPDATE yourtablename SET Guest=False, Presenter=False, TempAttendance=False"
    Me.Refresh
    End Sub
    Last edited by June7; 07-24-2018 at 06:33 PM.
    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.

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    OK, I've had a look at your DB. The checkboxes are BOUND to table Coalition Attendees. If you set them to ANY value, the value in the table changes. Is that what you want?
    Each row on the form represents a record in Coalition Attendees since it is a continuous form. To null all the checkboxes in the form requires an update to EVERY record in Coalition Attendees, which can be done via an update query:
    Code:
    Private Sub cmdClearBoxes_Click()
        Dim sSQL As String
        sSQL = "Update [Coalition Attendees] Set TempAttendance = False, Guest = False, Presenter = False"
        CurrentDb.Execute sSQL, dbFailOnError
        Me.Refresh
    End Sub
    If you don't want every record changed, the code above will need criteria added to restrict the scope of the change, such as specifying 'Active' or a specific 'Company/Organization', etc.

    Edit: I see that June7 and I are on same track!
    Last edited by davegri; 07-24-2018 at 04:39 PM. Reason: clarif

  11. #11
    kloun04 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Wisconsin
    Posts
    33

    Thumbs up

    Perfect! This is what I want.
    June7, thanks for the code.
    Davegri thanks for identifying that my boxes were bound to the coalition attendees table, i completely overlooked that. I was only looking at the append table. Now this makes sense.

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

Similar Threads

  1. Multisearch textboxes on split form
    By jaryszek in forum Access
    Replies: 7
    Last Post: 11-21-2017, 12:36 AM
  2. two textboxes in form to one cell in table
    By WickidWe in forum Forms
    Replies: 2
    Last Post: 12-12-2013, 05:25 PM
  3. All Textboxes Read-Only on Form
    By cbrsix in forum Programming
    Replies: 5
    Last Post: 04-16-2013, 01:47 PM
  4. Just numeric input for all textboxes in the form
    By amd711 in forum Programming
    Replies: 7
    Last Post: 11-27-2012, 08:08 AM
  5. Form - CANNOT EDIT TEXTBOXES !!!
    By dbalilti in forum Access
    Replies: 5
    Last Post: 07-05-2012, 12:15 PM

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