Controls and Multiple Records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a query as its control source. The form will be used to
update the status of employees as "active", with "Y" for Yes and "N" for No.
Rather than have the user have to update each record individually, I would
like the user to be able to check a checkbox and the records be updated. The
code I have so far is:

Private Sub chkUpdateAll_Click()

Dim ctl As Control

' Loop through the controls
For Each ctl In Me.Controls
' Check the control name
If ctl.Name = "Active" Then
ctl.Value = "Y"
End If
Next

End Sub

The code above works only for the active record. How do I get the all the
records updated as once? Is it better to use a continuous form in this
instance? I tried to update it via the recordset but I was unsuccessful. Thx
 
suggest you try using an Update query, and after it runs then you can
requery the form to show the updated values.

hth


xRoachx said:
I have a form with a query as its control source. The form will be used to
update the status of employees as "active", with "Y" for Yes and "N" for No.
Rather than have the user have to update each record individually, I would
like the user to be able to check a checkbox and the records be updated. The
code I have so far is:

Private Sub chkUpdateAll_Click()

Dim ctl As Control

' Loop through the controls
For Each ctl In Me.Controls
' Check the control name
If ctl.Name = "Active" Then
ctl.Value = "Y"
End If
Next

End Sub

The code above works only for the active record. How do I get the all the
records updated as once? Is it better to use a continuous form in this
instance? I tried to update it via the recordset but I was unsuccessful.
Thx
 
Back
Top