Selecting and deselecting multiple check boxes (1 Viewer)

DJBummy

Registered User.
Local time
Today, 03:51
Joined
Jun 22, 2001
Messages
90
I have 2 buttons on a main form that select or deselect multiple check boxes on a subform.
The reason is when a user selects from a combo box it could populate the subform with 100's of records. I want the user to be able to reset his selection if he made a mistake after selecting all of the check boxes with the first button.
Works fine when selecting all of the chkboxes but when i try to deselect it does nothing until I exit the form and come back in then I am able to deselect.
Am i missing something here. It seems like I am stuck in a loop or not closing something properly.

Below is the code

Code:
Private Sub cmdAll_Click()
    Dim rs As DAO.Recordset
    Set rs = Forms!frmEquipmentRemoveGroup!sbfEquipmentRemoveGroup.Form.RecordsetClone
    Do While Not rs.EOF
        If rs.RecordCount = 0 Then
            Exit Do
        End If
        rs.Edit
        rs!EquipActive = True
        rs.Update
        rs.MoveNext
    Loop
    Forms!frmEquipmentRemoveGroup.sbfEquipmentRemoveGroup.Form.Requery
    rs.Close
    Set rs = Nothing
    
    Exit Sub
End Sub[/EndCode]
[Code]
Private Sub cmdAllReset_Click()
    
    Dim rst As DAO.Recordset
    Set rst = Forms!frmEquipmentRemoveGroup!sbfEquipmentRemoveGroup.Form.RecordsetClone
    Do While Not rst.EOF
        If rst.RecordCount = 0 Then
            Exit Do
        End If
        rst.Edit
        rst!EquipActive = False
        rst.Update
        rst.MoveNext
    Loop
    Forms!frmEquipmentRemoveGroup.sbfEquipmentRemoveGroup.Form.Requery
    rst.Close
    Set rst = Nothing
    
    Exit Sub
End Sub[/EndCode]

Thank You
 

boblarson

Smeghead
Local time
Yesterday, 19:51
Joined
Jan 12, 2001
Messages
32,059
If there is a field to which you are bound, don't use a recordset and iterate through - just use an update query.
 

DJBummy

Registered User.
Local time
Today, 03:51
Joined
Jun 22, 2001
Messages
90
Thanks BOB. Worked just fine. Like they say. Keep it simple.
 

Users who are viewing this thread

Top Bottom