I am working on a form in an Access 2003 database (using ADO). The detail section of my form has as checkbox named ‘Select’ that occurs once for each row of data. I have placed another checkbox in the header of the form named ‘SelectAll’. When ‘SelectAll’ is modified, I want to modify every occurrence of the ‘Select’ checkbox in the detail section. I looked through several posts and have played around with the code, but I have received an error on everything that I have attempted.
I have figured out how to loop through the recordset, but I cannot seem to isolate the checkbox in each row of the form and set its value to either True or False. I have tried it four different ways (one at a time). I have included all four examples below. I would appreciate any help that I can get.
Thank you in advance for your help.
Mark
I have figured out how to loop through the recordset, but I cannot seem to isolate the checkbox in each row of the form and set its value to either True or False. I have tried it four different ways (one at a time). I have included all four examples below. I would appreciate any help that I can get.
Code:
Dim tmpcontrol As Controls Dim bSelectAll As Boolean bSelectAll = Me.SelectAll.Value ‘Checkbox in the Form Header For indx = 0 To (Me.Form.Recordset.RecordCount - 1) ‘Attempt 1 Me.Select.OptionValue = bSelectAll ‘Attempt 2 Me.Select(indx).Value = bSelectAll ‘Attempt 3 For Each tmpcontrol In [CourseInfoForm].Form.Controls If tmpcontrol.ControlType = acCheckBox Then tmpcontrol.Value = bSelectAll End If Next tmpcontrol ‘Attempt 4 For Each tmpcontrol In [CourseInfoForm].Form.Controls If tmpcontrol.Name = "Select" Then tmpcontrol.Value = bSelectAll End If Next tmpcontrol Next
Mark
Comment