check - uncheck in a continuous form

J

jean.ulrich

Hi

I have an unbound form name "Letter "
On this form I have a continuous form named "frmEmployees" linked
with the table "tblEmployees"
In the continuous form I have many fields including "City" and
"Choice" both linked with table "tblEmployees"
Field "Choice" is a check box (yes/no)

Suppose I make a filter on New-York city, I want to use a button placed
on the from header of the "frmEmployees" that when I click on it
all the check boxes "Choice" for New-York will become checked.
Then I filter for Denver and by clicking the same button, all the
"Choice" check boxes for Denver will be checked
Of course I can check some other records if I want
So at the end all check boxes for New-York all check boxes for Denver
plus all other single boxes I have check are checked.

I also want a second button that I will use to uncheck all check boxes.

Thanks for helping me
 
A

Allen Browne

Use the AfterUpdate event procedure of the unbound check box to execute an
Update query statement so that all the entries matching the form's filter
are set to Yes

Private Sub chk1_AfterUpdate
Dim strSql As String
If Me.chk1.Value And Me.FilterOn Then
If Me.Dirty Then 'Save first
Me.Dirty = False
End If
strSql = "UPDATE [Table1] SET Choice = True WHERE " & Me.Filter
dbEngine(0)(0).Execute strSql, dbFailOnError
End If
End Sub

To reset all boxes to unchecked again, execute this string:
strSql = "UPDATE [Table1] SET Choice = False WHERE Choice = True;"
 
J

jean.ulrich

Hi
there is no unbound check box
Check box "Choice" is a field in "tblEmployees"
so i cannot us the after update event like you said
Script should be place on the On Click event of the button

thanks
 
J

jean.ulrich

Thank Allen

The code was ok to put on the button except for the
"If Me.chk1.Value And Me.FilterOn Then "
that I have to replace by
"If Me.FilterOn Then "

Thanks gain, it works fine now
 

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