AfterUpdate code to change field values in current record only indatasheet view

R

RussCRM

I have a list on a form in datasheet view similar to this:

Last First BedAssigned Breakfast Lunch Dinner
Bed All
Smith John 12 [X] [X]
[X] [X] [X]
Thomas Tom 7 [ ] [ ]
[X] [X] [ ]
Doe Jane 9 [X]
[ ] [X] [X] [ ]

When a user clicks on/off the All checkbox, I want to change the
values of Breakfast, Lunch, Dinner, & Bed accordingly. For instance,
when they click the All box, it sets all the others as checked and
turns them off when unchecked.

Here's what I have so far, but it ends up checking on/off all the
boxes in my datasheet, not just the ones for the current record. What
am I missing?

Private Sub chkAll_AfterUpdate()
If chkAll.Value = True Then
chkBreakfast.Value = -1
chkLunch.Value = -1
chkDinner.Value = -1
Else
chkBreakfast.Value = 0
chkLunch.Value = 0
chkDinner.Value = 0
End If
End Sub
 

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