Change checkbox

MvP14

Registered User.
Local time
Today, 22:27
Joined
Apr 15, 2003
Messages
66
Hi,

I have a form based on a query. On the query is a button to print a report. Since a user may not want to print all records, I have added a checkbox on the form. The default value of the checkbox is false. The report filters on the checkbox being true.

All is fine, when the user marks records seperately.

However, I tried to add a button mark all, but when clicked, it only marks the current record.

This is the code I have so far:

Private Sub CheckAll_Click
Dim ctl As Control
Dim intCount As Integer

For Each ctl In Me.Controls
If ctl.ControlType = acCheckbox Then
ctl = True
End If
Next ctl
End Sub

Can anyone help me out here?
 
Is the checkbox bound to a field on the table? Is the form a continouse form?
If the checkbox sets a flag in the table, use a query to set all of them. If the form only shows one record at a time, than you only have one record the control is tied to at any given time.
 
The checkbox is indeed bound to the table. The form is not a continuous form.

What kind of query should I use? Or how els can I solve the problem. I'm puzzled here.
 
With a single form on display, the checkbox is only tied to that one record. You do NOT have a checkbox for each record, but as each record becomes current on the form, the checkbox applies to that record. So what you need is an update query that set all the checkboxes to true. When you click your button, use a macro/docmd to open that query. Basically the query would be something like:
UPDATE MyTable
SET Checkbox1 = True

and would set all of them to checked. You can add a WHERE to it, but I would design it in the GUI. Hope that helps
 
Thank you for your help. Before I try it out: are you aware of a more efficient way to do what I am trying to do? (I'm quite new to Access and VBA)
 

Users who are viewing this thread

Back
Top Bottom