Check Box (1 Viewer)

gselliott

Registered User.
Local time
Today, 22:16
Joined
May 17, 2002
Messages
106
I would to place a check box or button (dont mind which) on my continuous form that when clicked will select all of the check boxes on the form. The form is going to be used to allow the user to select which records will be displayed on an invoice.

I have got this working so that the user can select each individual record but in some cases there could be over 150 records and if they want them all to appear they will have to click each of the 150 check boxes on the form.

Any ideas would be appreciated.

Thanks
 

GJT

Registered User.
Local time
Today, 22:16
Joined
Nov 5, 2002
Messages
116
Dont know if this is of interest ??

Simply, place a check box control on your form and leave the control source property empty and hey presto when one box is selected ALL are selected!

You will need to write a routine on Form_Close/Update to inspect the value of this field (1 field only- if this is checked ALL are checked remember!), and do whatever processing needs to be doen for your filtering requirement. However, if you also wish to permit individual selection, you will need another check box on the form that is bound to the appropriate table field.

HTH

G
:cool:
 

gselliott

Registered User.
Local time
Today, 22:16
Joined
May 17, 2002
Messages
106
Thanks for your reply.

I have tried putting a Checkbox on and putting the code in the AfterUpdate of the Checkbox it works but only for one record.

Obviously im doing something wrong?
 

Mile-O

Back once again...
Local time
Today, 22:16
Joined
Dec 10, 2002
Messages
11,316
Code:
Dim ctl As Control

For Each ctl In Me
    If ctl.ControlType = acCheckBox Then
        ctl = True
    End If
Next
 

GJT

Registered User.
Local time
Today, 22:16
Joined
Nov 5, 2002
Messages
116
I wouldn't put any code in the AfterUpdate() event of the check box - leave any validation to the Form_Update event or Form_Close.

What are you doing in the Update() event?
 

IMO

Now Known as ___
Local time
Today, 22:16
Joined
Sep 11, 2002
Messages
723
You could try this, place an unbound checkbox in the forms header or footer, set its default value to False and in the OnClick event put the following code changing all in red to the correct Names...
Code:
Private Sub [COLOR=red]YourUnboundCheckBox[/COLOR]_Click()
    
    If Me.[COLOR=red]YourUnboundCheckBox[/COLOR] = True Then
        DoCmd.RunCommand acCmdSaveRecord
        DoCmd.RunSQL "UPDATE [COLOR=red]YourTableName[/COLOR] SET [COLOR=red]YourTableName[/COLOR].[[COLOR=red]CheckBoxColumn[/COLOR]] = True WHERE ((([COLOR=red]YourTableName[/COLOR].[[COLOR=red]CheckBoxColumn[/COLOR]])=False));"
        DoCmd.Requery
    Else
        DoCmd.RunCommand acCmdSaveRecord
        DoCmd.RunSQL "UPDATE [COLOR=red]YourTableName[/COLOR] SET [COLOR=red]YourTableName[/COLOR].[[COLOR=red]CheckBoxColumn[/COLOR]] = False WHERE ((([COLOR=red]YourTableName[/COLOR].[[COLOR=red]CheckBoxColumn[/COLOR]])=True));"
        DoCmd.Requery
    End If

End Sub
HTH
IMO
 

gselliott

Registered User.
Local time
Today, 22:16
Joined
May 17, 2002
Messages
106
IMO

Thanks for your help that worked a treat!
 

IMO

Now Known as ___
Local time
Today, 22:16
Joined
Sep 11, 2002
Messages
723
Glad it worked. Just forgot one thing, in the OnClick event of the Bound checkbox, put...
Code:
Private Sub YourBoundCheckbox_Click()

      Me.YourUnboundCheckBox= False

End Sub
so if all records are selected and one record is deselected, the "select all" checkbox is ready to select all again, if you see what I mean :confused:

HTH
IMO
 

Users who are viewing this thread

Top Bottom