Continious forms record source loop

C

Chris

Hello group,
I have a main form (frmMain) and a subform (frmCrane) On frmMain I have a
check box that when ticked will make all the checkboxes in the subform
ticked.

frmcrane is a continious form and therefore has around 19 tickboxes (1 for
each record ).

I am using the code on the frmMain checkbox
Forms!Frmcrane.form.chkStandard = me.chkstandardRate

The results are that what ever record on the sub form is selected will equal
the checkbox on the mainform.

However I would like all the checkboxes to equal the checkbox on the main
form
 
A

Al Campagna

Chris,
You wrote...
However I would like all the checkboxes to equal the checkbox on the main form

You shouldn't do that. It would be redundant. If the Main form is checked... because
all subform records are related to the main... it is implied that those subform records
are associated with the checkbox on the main. It's not necessary to then have each
subform record given that same logical value.

You didn't give any info as to what the checkbox means, but for example...

Say the checkbox on the Main indicated [UnderRepair] (not available for work).
Every Crane in the subform, through it's relationship with the Main is, by that
relationship, considered UnderRepair. In any query or report, via that UnderRepair field,
you can filter out, or identify, any Crane's whivh are/are not UnderRepair.
(this may not be the best example, but I hope you see the logic as to why to avoid
that redundancy)
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
A

Albert D. Kallal

As the other poster mentieond, if all check boxes need to always be the
same, then you can use the releoatnla abilireys of the system, and NEVER
have to run a udpate, or even have that check box field in the sub-forms
reocrds.

However, ignoring the above adivice, the code to do this would be placned in
the main forms check box after update evnet.

The code do do this would be:

dim strSql as string

strSql = "update tblSubform set checkBox = True where main_id = " & me!id
currentdb.execute strSql
me.mySubForm.Requery

replace "tblSubForm" with the name of the table that the sub-form is based
on.
change "main_id" to the field name in the sub-form table used to *relate*
back to the main form
change md!id (the id part) to the name of the primary key field used in the
main form (usually id).
change mySubForm to the name of the sub-form CONTROL used on your main form
(note I said control, not name of the actual sub-form).

Now, of course if you add more records to the sub-form, then you have to
run the above code again, and that just points us back to the first
suggestion...
 

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