Re: Validation of multiple check boxes
- From: dsc2bjn <dsc2bjn@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 6 Aug 2007 15:28:01 -0700
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
- References:
- Re: Validation of multiple check boxes
- From: Douglas J. Steele
- Re: Validation of multiple check boxes
- From: dsc2bjn
- Re: Validation of multiple check boxes
- From: Graham Mandeno
- Re: Validation of multiple check boxes
- Prev by Date: Re: concatenate query results to a string
- Next by Date: Re: concatenate query results to a string
- Previous by thread: Re: Validation of multiple check boxes
- Next by thread: RE: Validation of multiple check boxes
- Index(es):
Relevant Pages
|