Re: Validation of multiple check boxes

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks!!

That works well.

"Graham Mandeno" wrote:

Notice that Doug said:
If the total was 0, that would mean that no check boxes were checked. If
the
total was > 1, that would mean that more than 1 checkbox was checked.

So, instead of testing for a total that is not exactly 1, you should test
for a total of zero.

Change <> 1 to = 0
--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

"dsc2bjn" <dsc2bjn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:906B5754-065A-4D13-8D4D-390A5D38CFC0@xxxxxxxxxxxxxxxx
I am looking to ensure AT LEAST one box is checked. The user could check
all
9 boxes. That is the reason for evaluating the "group" was to make sure
all
the check boxes were not blank.

"Douglas J. Steele" wrote:

There should be no need to use the Eval function.

To check that only one check box is checked, you can use something like:

If Abs([Forms]![SAR Data Entry]![Confirmation] + _
[Forms]![SAR Data Entry]![DOCUMENT ANALYSIS] + _
[Forms]![SAR Data Entry]![Interview] + _
[Forms]![SAR Data Entry]![Observation] + _
[Forms]![SAR Data Entry]![Physical Examination] + _
[Forms]![SAR Data Entry]![QUESTIONNAIRE] + _
[Forms]![SAR Data Entry]![Sampling]=0 +_
[Forms]![SAR Data Entry]![TRANSACTION TESTING] + _
[Forms]![SAR Data Entry]![TO BE DETERMINED]) <> 1 Then
MsgBox "You haven't checked only 1 checkbox.", vbOKOnly, "Message
title"
End If

This takes advantage of the fact that True is -1 and False is 0 in
Access.
If the total was 0, that would mean that no check boxes were checked. If
the
total was > 1, that would mean that more than 1 checkbox was checked.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"dsc2bjn" <dsc2bjn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0219F2F5-3EB9-44FF-9F8E-EC2CF7F5427A@xxxxxxxxxxxxxxxx
I have a form with 9 check boxes. Each check box represents a data
element
within the same table. Only 1 of the check boxes must be checked in
order
for the record to be accepted into the data table.

I have written a validation which works for other required values;
however,
when the same logic is applied to the check box nothing happens. The
message
box does not appear. If I change the "0" value (which should represent
an
unchecked box) to 1, the validation works fine (all check boxes are
checked).


What is wrong with this:

On Error GoTo Err_Command44_Click
If (Eval("[Forms]![SAR Data Entry]![Confirmation]=0")) And _
(Eval("[Forms]![SAR Data Entry]![DOCUMENT ANALYSIS]=0")) And _
(Eval("[Forms]![SAR Data Entry]![Interview]=0")) And _
(Eval("[Forms]![SAR Data Entry]![Observation]=0")) And _
(Eval("[Forms]![SAR Data Entry]![Physical Examination]=0")) And _
(Eval("[Forms]![SAR Data Entry]![QUESTIONNAIRE]=0")) And _
(Eval("[Forms]![SAR Data Entry]![Sampling]=0")) And _
(Eval("[Forms]![SAR Data Entry]![TRANSACTION TESTING]=0")) And _
(Eval("[Forms]![SAR Data Entry]![TO BE DETERMINED]=0")) Then
MsgBox "A Value for 'Testing Methods' is Required.", vbOKOnly,
"Message
title"
End If
If (Eval("[Forms]![SAR Data Entry]![AU] Is Null")) Then
MsgBox "A Value for 'AU' is Required.", vbOKOnly, "Message title"
End If
If (Eval("[Forms]![SAR Data Entry]![SAR Question] Is Null")) Then
MsgBox "A Value for 'SAR Question' is Required.", vbOKOnly,
"Message
title"
End If
If (Eval("[Forms]![SAR Data Entry]![Weakness] Is Null")) Then
MsgBox "A Value for 'Weakness' is Required.", vbOKOnly, "Message
title"
Else
DoCmd.Close
End If
Exit_Command44_Click:
Exit Sub

Err_Command44_Click:
MsgBox Err.Description
Resume Exit_Command44_Click

End Sub






.



Relevant Pages

  • Re: Validation of multiple check boxes
    ... that would mean that more than 1 checkbox was checked. ... the check boxes were not blank. ... MsgBox "You haven't checked only 1 checkbox.", vbOKOnly, "Message ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.formscoding)
  • Re: Edit Chart Data in a Word 2007 Template using grouped CheckBox
    ... Sub ExclusiveCheckBoxes() ... Dim ChkStart As String ... ' Find all the other members of this group and clear them - yes this will also clear the selected checkbox ... The zero's are the boxes. ...
    (microsoft.public.word.vba.beginners)
  • Re: Help with CommandButton vs Excel 2002
    ... I don't use a Mac, but from posts I've read, Mac's don't support controls from ... You can create a macro in a General module and assign it to each checkbox. ... sub CheckBoxClick() ... msgbox "it's not checked" ...
    (microsoft.public.excel.programming)
  • Re: Help with macro to check validation rule
    ... By putting the code in the Exit event, the user can still check both ... If he checks the Female checkbox and hits TAB, ... text boxes, etc.). ...
    (microsoft.public.word.vba.general)
  • Re: CheckBoxes Stack up when Rows are hidden and unhidden
    ... I can now unhide the check boxes but I now want to differentiate between ... "Dave Peterson" wrote: ... I've created the check boxes from selecting them from the Control Toolbox ... The checkbox from the Forms toolbar does not allow this setting. ...
    (microsoft.public.excel.worksheet.functions)