Glint said:
Thanx Marshal,
But I don't seem to understand your code. Basically what I want to avoid is
double entry between 1 and 80. Any textbox can take any number or null; once
a number is entered into a textbox however, no other textbox should accept
that number for that record. In other words, for every record, the numbers
are unique to fields.
I tried your code and I did not get much result.
Gee, Glint, "I did not get much result" really doesn't
provide me with enough information to figure out what you
did or what happend.
So, ok, I went and built an unbound form with your
arrangement and noticed two issues. One, the Undo method
doesn't seem to work for Me.ActiveControl(??) so I removed
that line and, two, I forgot to cancel the event so the bad
text box wouldn't lose the focus. This is the new version
of the function:
Public Function ChkAll()
Dim K As Integer
For K = 1 To 80
If Me.ActiveControl = Me("txt" & K) Then
If Me.ActiveControl.Name <> "txt" & K Then
Beep
DoCmd.CancelEvent
End If
End If
Next K
End Function
The idea behind the function is that every time a value is
entered in any of the text boxes, it checks to see if any
other box has the same value. Once a value is accepted, the
entire set of values up to that point are guaranteed not to
have any duplicates. Since this will be true up to and
including when the 80th box is assigned a value, it should
meet the stated objective.