Controls and Multiple Records

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
 
T

tina

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top