Sync check-box on main form with check-boxes on sub-form (1 Viewer)

frankt68

Registered User.
Local time
Today, 19:13
Joined
Mar 14, 2012
Messages
90
I have a master form and a sub-form showing records that meet the required criteria.
On the main form, I have one check-box, and on the sub-form (datasheet view), I have a check-box for each record.
When I click on the check-box on the main form, the status (checked / unchecked) of the check-boxes on the subform changes as well. For this, I use the following code with On Click event:



Code:
Private Sub Selection_Click()

RunCommand acCmdSubdatasheetExpandAll 


Dim rs As DAO.Recordset
Set rs = Me.[Subform_name].Form.RecordsetClone
With rs
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
.Edit
![Selection].Value = Me.Selection.Value
.Update
.MoveNext
Wend
.Close
End With
Set rs = Nothing
RunCommand acCmdSubdatasheetCollapseAll

Me.Requery
End Sub
What I would like to do is to click on any check-box on the sub-form and change the status (checked/unchecked) of all other check-boxes on the sub-form and the main form.

Please advise how I can do that.
 

June7

AWF VIP
Local time
Today, 09:13
Joined
Mar 9, 2014
Messages
5,468
So you have 2 checkboxes, one on main form and one on subform? Are these checkboxes bound to fields?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:13
Joined
May 7, 2009
Messages
19,230
change the main form's selection_click to Public sub.
add code to the subform's selection click event:
Code:
private sub selection_click()
    me.parent!selection = me.selection
    me.parent.dirty = false
    call me.parent.selection_click
end sub
 

frankt68

Registered User.
Local time
Today, 19:13
Joined
Mar 14, 2012
Messages
90
change the main form's selection_click to Public sub.
add code to the subform's selection click event:
Code:
private sub selection_click()
    me.parent!selection = me.selection
    me.parent.dirty = false
    call me.parent.selection_click
 end sub


Works great!
 

Users who are viewing this thread

Top Bottom