User must Check atleast One CheckBox from Three

  • Thread starter Malik via AccessMonster.com
  • Start date
M

Malik via AccessMonster.com

Hi

I Have three CheckBoxes in my form. I want that user must Check Atleast One
Checkbox from these three boxes.
Thanks
 
J

Jeanette Cunningham

Hi Malik
Create the check boxes with similar name, with a different number in the end

Check1, check2, check3 ...
..........................................
Create a function in the form that loops through the records

Function CheckAmountOfCheck()
Dim lngI as Long
Dim lngSum as Long
CheckAmountOfCheck = False

For lngI = 1 To 3
lngSum = lngSum + Abs(Me("Check" & lngI))
Next lngI

If lngSum <= 0 Then
MsgBox "Must check at least one check box"
CheckAmountOfCheck = True
End If

End Function


On the before update event of the form you can put

If CheckAmountOfCheck = True Then
Cancel = True
End If

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

malik via AccessMonster.com

Jeanette said:
Hi Malik
Create the check boxes with similar name, with a different number in the end

Check1, check2, check3 ...
.........................................
Create a function in the form that loops through the records

Function CheckAmountOfCheck()
Dim lngI as Long
Dim lngSum as Long



Thank you very much
 
M

malik via AccessMonster.com

Jeanette said:
Hi Malik
Create the check boxes with similar name, with a different number in the end

Check1, check2, check3 ...
.........................................
Create a function in the form that loops through the records

Function CheckAmountOfCheck()
Dim lngI as Long
Dim lngSum as Long



Thank you very much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top