Select All Un-Select All

Flynners

Registered User.
Local time
Today, 07:38
Joined
Mar 1, 2012
Messages
29
Hi all
I have a continuous form with check box. I have created two buttons. one to select all and one to unselect all.
I have button SelectAll with following onclick event
With Me.RecordsetClone
Do Until .EOF
.Edit
!ShortList = True
.Update
.MoveNext
Loop
End With

I have button UnSelectAll with the following onclick event
With Me.RecordsetClone
Do Until .EOF
.Edit
!ShortList = False
.Update
.MoveNext
Loop
End With

These buttons work individually if the form is just opened.
However if i click selectall and then click unselect all (anticipating what the user may do) in succession it doesnt work. ie all still selected
I tried save after end with statement, Ive tried requery the form but neither work

I basically want an undo if the user selects all accidently. Is there a better way of achieving this.

thanks
 
An easier and quicker way to do this is to create an update query that is fired by a command button. Here are the two commands and the SQL for the queries. You could do this with one command button making the two docmd lines as part of an IF-THEN statement.
Code:
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryCheck"
    DoCmd.SetWarnings True

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryUnCheck"
    DoCmd.SetWarnings True

To uncheck run this query called qryUnCheck

UPDATE Table1 SET Table1.chkBox = 0
WHERE (((TAble1.chkBox)=-1));

To fill the checkbox, run this query

UPDATE Table1 SET Table1.chkBox = -1
WHERE (((TAble1.chkBox)=0));

Alan
 
thanks Alan, that worked great for me.
I did a bit of tweaking as my form was based on query rather than table but im happy with the results

much obliged
 

Users who are viewing this thread

Back
Top Bottom