Validation rule for text boxes?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 2 tick boxes: 'new' and refurb'
I want it so that only one can be ticked or the other, not both
I cannot change the underlying table, so that the tick boxes are radio boxes, as there are over 1000 records, and this would alter them all
Is there a validation rule I can add to the checkboxes on my form so that only one or the other can be checked>
Any ideas
Thank Yo
Alicia
 
You could put coding similar to below in the form's
BeforUpdate eventhandler

If {yourNewCheckBox} Then
If {yourRefurbCheckBox} Then
MsgBox "Both check boxes cannot be ticked"
Cancel = True
End If
ElseIf Not {yourRefurbCheckBox} Then
MsgBox "One check boxes must be ticked"
Cancel = True
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a form with 2 tick boxes: 'new' and refurb'.
I want it so that only one can be ticked or the other, not both.
I cannot change the underlying table, so that the tick
boxes are radio boxes, as there are over 1000 records, and
this would alter them all!
Is there a validation rule I can add to the checkboxes on
my form so that only one or the other can be checked>?
 
Thank you v much Gerald. The code worked perfectly
I have asked this question many times, and this is the first reply which has worked
----- Gerald Stanley wrote: ----

You could put coding similar to below in the form'
BeforUpdate eventhandle

If {yourNewCheckBox} The
If {yourRefurbCheckBox} The
MsgBox "Both check boxes cannot be ticked
Cancel = Tru
End I
ElseIf Not {yourRefurbCheckBox} The
MsgBox "One check boxes must be ticked
Cancel = Tru
End I

Hope This Help
Gerald Stanley MCS
-----Original Message----
I have a form with 2 tick boxes: 'new' and refurb'
I want it so that only one can be ticked or the other, no both
I cannot change the underlying table, so that the tic
boxes are radio boxes, as there are over 1000 records, an
this would alter them all
Is there a validation rule I can add to the checkboxes o
my form so that only one or the other can be checked>
 
This works.............

Private Sub Chk1_AfterUpdate()
If Chk1 = True Then
Me!chk2.Enabled = False
Else
If Chk1 = False Then
Me!chk2.Enabled = True
End If
End If

End Sub

Private Sub chk2_AfterUpdate()
If chk2 = True Then
Me!Chk1.Enabled = False
Else
If chk2 = False Then
Me!Chk1.Enabled = True
End If
End If

This doesn't prohibit NO chkboxes checked, however in conjunction with
Gerald's code, you should be all set!

HTH
Damon


End Sub
 
Back
Top