Record Select - checkbox

Hello, the below works fine but if I need t oadd functionality that if I click again then the checkbox will be false.   How could I modify the below?

Private Sub cmdRemoveOtherDept_Click()

     Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.MoveFirst
    Do Until rs.EOF
        rs.Edit
        ' Use your own field name here
        rs("RemoveFromReportOtherDept") = True
        rs.Update
        rs.MoveNext
    Loop
    Set rs = Nothing
        '***** omit this to avoid refreshing the screen
   ' Me.Requery

End Sub
pdvsaProject financeAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
do you mean like, toggle the value, if the current value is true, it will become false and vice versa?

Private Sub cmdRemoveOtherDept_Click()

      Dim rs As DAO.Recordset
     Set rs = Me.RecordsetClone
     rs.MoveFirst
     Do Until rs.EOF
         rs.Edit
         ' Use your own field name here
         rs("RemoveFromReportOtherDept") = Not rs("RemoveFromReportOtherDept")
         rs.Update
         rs.MoveNext
     Loop
     Set rs = Nothing

 End Sub
0
 
GozrehCommented:
Is the cmdRemoveOtherDept a checkbox ?

or do you have another checkbox on your form and do you want that rs("RemoveFromReportOtherDept")  should be updated the same as the checkbox value ?
0
 
pdvsaProject financeAuthor Commented:
Perfect!  Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.