How to validate that at least one checkbox is selected

Hi I have put your code into my db with the Nz function as well. The code is working!!! It will not work without the Nz function or if I leave out setting the check box to -1 afterwards. Why is it that it is only selectable if it is set to true? also please can you tell me what the cycle property is? also I only need the code in the main forms before update event, and not in the subform and it still works.
 
It will not work without the Nz function or if I leave out setting the check box to -1 afterwards. Why is it that it is only selectable if it is set to true?
Sorry, I don't understand. Can you post the code in question.
also please can you tell me what the cycle property is?
From the Access help file:
You can use the Cycle property to specify what happens when you press the TAB key and the focus is in the last control on a bound form. Read/write Byte.

expression.Cycle
expression Required. An expression that returns one of the objects in the Applies To list.

Remarks
The Cycle property uses the following settings.

Setting Visual Basic Description
All Records 0 (Default) Pressing the TAB key from the last control on a form moves the focus to the first control in the tab order in the next record.
Current Record 1 Pressing the TAB key from the last control on a record moves the focus to the first control in the tab order in the same record.
Current Page 2 Pressing the TAB key from the last control on a page moves the focus back to the first control in the tab order on the page.


Note You can set the Cycle property by using the form's property sheet, a macro, or Visual Basic .

You can set the Cycle property in any view.

When you press the TAB key on a form, the focus moves through the controls on the form according to each control's place in the tab order.

You can set the Cycle property to All Records for forms designed for data entry. This allows the user to move to a new record by pressing the TAB key.

Note The Cycle property only controls the TAB key behavior on the form where the property is set. If a subform control is in the tab order, once the subform control receives the focus, the Cycle property setting for the subform determines what happens when you press the TAB key.

To move the focus outside a subform control, press CTRL+TAB.
also I only need the code in the main forms before update event, and not in the subform and it still works.
I don't think so, but I will test.
 
also I only need the code in the main forms before update event, and not in the subform and it still works.
I have tried it, and without the validation code in the sub form, an existing sub form record can be edited and saved without one of the check boxes being selected. So, it does not work without it.
 
Sorry Bob, I did not mean it does not work. It works fine with your code. I was just thinking aloud on why it needs to set the check box to true to work correctly. Also I was just stating that the code works in the main form and therefore I do not need it in the other form.
 
Also I was just stating that the code works in the main form and therefore I do not need it in the other form.
Not true. See my post # 43 for reason.
 
sorry I really must read the detail.
No problem. As I said, If you don't understand, please ask.
I was just thinking aloud on why it needs to set the check box to true to work correctly.
I don't think it is necessary. I think it still works OK if that line is removed.
 

Users who are viewing this thread

Back
Top Bottom