Solved Continuous Form Loop (1 Viewer)

ZombeWalker71

New member
Local time
Today, 11:37
Joined
Mar 13, 2020
Messages
5
Hi, I have a continuous form that has a checkbox field on each row called 'Specials', When a user clicks a button in the Form Header, I want is to display a message asking the user if they want to remove the selections they have made. If they click Yes, the checkbox will update checkbox to False on ALL records

If they chose No, the data stays as it it is.

My code at the moment only updates the first record it finds, could someone tweak the code for me to loop through the entire recordset and change any checkboxes marked as true to false please

Code:
Private Sub Cmd_Reset_Selections_Click()

    On Error GoTo Err_Cmd_Reset_Selections_Click
    If MsgBox( _
            "Do you want to remove the selections you have made?", _
            vbYesNo, _
            "Update Selections?") _
        = vbYes _
Then
        Me.Specials = False
        Me.Dirty = False   ' save record
    End If

Exit_Cmd_Reset_Selections_Click:
     Exit Sub

Err_Cmd_Reset_Selections_Click:
    MsgBox Err.Description
    Resume Exit_Cmd_Reset_Selections_Click

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:37
Joined
Oct 29, 2018
Messages
21,358
Hi. Welcome to AWF!

You may not need a loop. An UPDATE query should do the same thing. For example:
Code:
If MsgBox(...) = vbYes Then
    If Me.Dirty Then Me.Dirty=False
    CurrentDb.Execute "UPDATE TableName SET Speicals=False", dbFailOnError
    Me.Requery
End If
 
Last edited:

ZombeWalker71

New member
Local time
Today, 11:37
Joined
Mar 13, 2020
Messages
5
As soon as I saw your message about an update query, I knew that would work.

Fantastic, thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:37
Joined
Oct 29, 2018
Messages
21,358
As soon as I saw your message about an update query, I knew that would work.

Fantastic, thank you
You're welcome. Glad we could assist. Good luck with your project.
 

Users who are viewing this thread

Top Bottom