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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Checkboxes 1

Status
Not open for further replies.

assiri

Technical User
Aug 17, 2008
17
0
0
GB
Hi,

I have ten checkBoxes in a access form(Check1,check2...etc) and I want to clear all other checkboxes,when I select a perticular checkBox.
As an example, If select Check2, all other checkBoxes should clear if they are selected.
If I select check4,all other checkboxes should be cleared.
(it behaves same as a option group,but I am not using an option group because ,I want to extend this line of checkBoxes twodimensionaly in future)
I tried to put the checkBox values in to a array and handle them,but it was unsucsesful.
Please give me any other method to handle set of checkboxes which behaves like an option group, without using the built in option groups comes with acesss.
Thank You

assiri
 
You could use an array:

Code:
Sub ClearChecks()
astrClear=Split("Chk1,Chk2,Chk3",",")
For Each itm In astrClear
   If itm<>ActiveControl.Name
        Me(itm)=False
   End If
Next

Then in the click event:

=ClearChecks


Or you could set the tag property of the relevant checkboxes to, say, Clear. Then in the click event:

=ClearChecks

And similar code.

Code:
Function ClearChecks()
'Function because you cannot call subs
'from event lines
For Each ctl In Me.Controls
   If ctl.Tag="Clear" And ctl.Name<>ActiveControl.Name
        clt=False
   End If
Next

The above is typed, not tested.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top