django
10-29-2001, 05:59 AM
I have installed check boxes linked to macros, which will allow users to print a specific record. I am now trying to figure out how to make a Clear all, and Mark all button for my boxes. Is this possible, and if so, what steps will get me there. I am using Access 97' if that makes any difference at all.
R. Hicks
10-29-2001, 06:28 AM
Here is the needed code:
To Clear all checkboxes on the form using a cmdButton use:
Dim ctl As Control
For Each ctl In Me.Controls
  If ctl.ControlType = acCheckBox Then
    ctl = 0
  End If
Next
To Check All checkboxes on the form using a cmdButton use:
Dim ctl As Control
For Each ctl In Me.Controls
  If ctl.ControlType = acCheckBox Then
    ctl = -1
  End If
Next
HTH
RDH
[This message has been edited by R. Hicks (edited 10-29-2001).]
django
10-29-2001, 12:56 PM
Thanks alot for the help! But I am not to familiar with modules or writing code. Should I make a new module, or make a button and add the code to it's event procedure? If I make a new module how do I make a command button act on the code. I looked to change the event procedure to the empty command buttons I made but could not find my new modules. By the way this is the best help board I have ever run into, Thanks again!
R. Hicks
10-29-2001, 01:15 PM
I have given you the code for both procedures you ask for. You need to place the correct code in the associated button using the On Click event of the buttons.
HTH
RDH
Little_Man22
10-29-2001, 02:41 PM
Hey R. Hicks,
I'm just curious but how would you write code to clear all of the fields in the form (i.e. checkboxes, comboboxes, etc).
Ryan.
R. Hicks
10-29-2001, 03:47 PM
Hello Ryan, the following can be used with an event to do what you ask. Beware that you can run into problems if the control is bound an expression or the result of a function.
Dim ctl As Control
For Each ctl In Me.Controls
* Select Case ctl.ControlType
* * Case acToggleButton
* * * ctl = False
* * Case acComboBox, acListBox
* * * ctl = Null
* * Case acCheckBox, acOptionButton
* * * ctl = False
* * Case acTextBox
* * * ctl = Null
* End Select
Next
HTH
RDH
[This message has been edited by R. Hicks (edited 10-29-2001).]
django
10-30-2001, 06:33 AM
Thanks R.Hicks I finally got it to work. But now I have another problem. I have two diff. check boxes on each record to mark seperate addresses. I would like a pair of clr all and mark all commands for for each check box. How or what can I change in my code to make the commands act on only one specific check box and ignore the other chk box?