Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check box control 1

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi
Need some help please with this one
I have a continous form which has a check box in the detail section to add totals.
At times I need to tick individual check boxes. At other times I need to check them all. Is there a way if I put a check box in the form header, that by a check in that check box would check all the check boxes in the detail section.
Hope this makes sense

Many thanks
 
Hi all,
Sorry to repost this question, but is there a possible solution to this problem.

Man thanks
 
Yes but it would help if you provide some details on your tables and fields that are used. This can not be done if the checkbox in the detail section is unbound. The easiest way is on the afterupdate event of the header checkbox you run an update query on the query that provides the records for the detail section. Please provide the table names, fields, and queries. Look at the docmd.runsql or Currentdb.execute. You can also use a recordset to loop the records, but that is not preferred.
 
Hi MajP
Many thanks for your reply.
Yes the checkbox is bound to the table. the table name is "accounts", the chkbox is chk1,which is in the detail section.
The checkbox in the header is unbound.(Chkbox2)
The query that runs the form is a select query, which holds all the field. The query is QAccounts.
But I do not know where to from from here.

Many thanks.
 
Hoew are ya techkenny1 . . .
techkenny1 said:
[blue]Is there a way if I put a check box in the form header, that by a check in that check box would check all the check boxes in the detail section.[/blue]
Yes ... can be done! Try the folowing in the [blue]AfterUpdate[/blue] event of the [blue]checkbox in the header[/blue] ([blue]you![/blue] substitute proper names in [purple]purple[/purple]):
Code:
[blue]   Dim rst As DAO.Recordset
   
   Set rst = Me.RecordsetClone
   
   Do
      rst.Edit
      rst![purple][b][DetailChkBoxName][/b][/purple] = Me![purple][b][HdrChkBoxName][/b][/purple]
      rst.Update
      rst.MoveNext
   Loop Until rst.EOF[/blue]
Note: The code follows the state of the checkbox in the hearder, [blue]allowing you to toggle![/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Just what I was looking for but...
When I tick the check box, all the detail boxes are checked. However, it doesn't work as a toggle. I used your code and added a close statement but it doesn't toggle.
There are two fields that I need to set this way, a check box and a date. Then I set the check box to select all, the date select all does not work. I must close/open the form and then set the dates.

I would appreciate any suggestions?


Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
Do While Not rst.EOF
rst.Edit
rst![Select] = Me![Check_All]
rst.Update
rst.MoveNext
Loop
rst.Close


Set rst = Me.RecordsetClone
Do While Not rst.EOF
rst.Edit
rst![SDate] = Me![Set_Date]
rst.Update
rst.MoveNext
Loop
rst.Close
 
Problem solved.
I put a rst.MoveFirst at the beginning of the both sets of code.

Set rst = Me.RecordsetClone
rst.MoveFirst
Do While Not rst.EOF
rst.Edit
rst![Select] = Me.Check_All
rst.Update
rst.MoveNext
Loop
rst.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top