Selecting multiple checkboxes on subform (1 Viewer)

frankt68

Registered User.
Local time
Today, 02:34
Joined
Mar 14, 2012
Messages
90
Hi!

I'd like to know how can I select/deselect the checkboxes for all records on the subform when I select/deselect the checkbox on the main form?
I tried the code
Code:
Private Sub MySelection_AfterUpdate()
Me.Subform2.Form!MySelection1.Value = Me.MySelection.Value
End Sub

but this only select the first record of all records on the subform.
Any suggestion would be appreciated.
 

Isskint

Slowly Developing
Local time
Today, 01:34
Joined
Apr 25, 2012
Messages
1,302
hi Frank

Assuming they are bound, you would need an update query, either an existing query or run SQL on the fly. Your query would need to say update fieldX to value of fieldY on FormZ where join field = FormZ.join field.

Are the check boxes on the subform bound to a field in a table?
What are the names of the tables for the main form and the subform?
what are the relevant field names?
What is the joining field (PK on the main table, FK on the second table?)?
 

frankt68

Registered User.
Local time
Today, 02:34
Joined
Mar 14, 2012
Messages
90
Hi Isskint and thanx for the tip.

I made a query as you suggested, but it's not working as it should because it affects all records in the table and not only those it should.
Are the check boxes on the subform bound to a field in a table?
What are the names of the tables for the main form and the subform?
Yes, they are. The checkbox "MySelection" on the main form "fGroups" is bound to the table "tGroups" field "Groups_Selection". The checkbox "MySelection1" on the subform "subfOffers" is bound to the table "tOffers" field "Item_Selection".

what are the relevant field names?
I don't quite understand what do you mean by relevant field names.
On the main form, there are fields like group_ID, supplier_name, offer_ID, price, and total_sum and the checkbox "MySelection"which is bound to the table "tGroups" field "Groups_Selection".
On the subform, there are fields like group_ID, supplier_name, offer_ID, item_ID, item_name, price, etc. and the checkbox "MySelection1" which is bound to the table "tOffers" field "Item_Selection"

What is the joining field (PK on the main table, FK on the second table?)?
By now it is probably clear that I do not know much about Access, so I don't quite understand this neither, but I guess PK stands for Primary Key and FK for Foreign Key. If that's the case then I'm a bit lost, because I don't have it. If it would be of any help, I linked the main form with a subform using fields group_ID, supplier_name, and offer_ID. As you can see those fields are in both forms and both tables.

I would appreciate any additional advice.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:34
Joined
May 7, 2009
Messages
19,231
you do it in the subforms recordset.
on the click event of your checkbox on the main form:

private sub mainFormCheckboxName_click()
dim rs as dao.recordset
set rs = me.yoursubformName.Form.RecordsetClone
with rs
if not (.bof and .eof) then .movefirst
while not .eof
.edit
![comboFieldNameOfSubform].Value = me.MainCheckboxName.Value
.update
.movenext
wend
.close
end with
set rs=nothing
end sub

replaced the blue ones with correct subform and control name.
 

Users who are viewing this thread

Top Bottom