View Single Post
  #16  
Old May 15th, 2009, 01:50 PM posted to microsoft.public.access.tablesdbdesign
Russ[_2_]
external usenet poster
 
Posts: 52
Default No duplicate records problem

On Thu, 14 May 2009 20:18:34 -0600, John W. Vinson
wrote:

On Thu, 14 May 2009 20:50:04 -0500, Russ wrote:

The code assumes that your Subform has controls named [E85No] and [ItemNo]. If
it doesn't, add controls of those names bound to the corresponding fields, or
(perhaps better) textboxes named txtE85No and txtItemNo and replace the
Me![E85No] and Me![ItemNo] references with Me![txtE85No] and Me![txtItemno].
The textboxes can be invisible if you wish.


I changed the field types to Number Long integer. In the ItemNo field
of the form, I've got 4 in the validation rule property. When I
enter 4 in that field I get the required validation text I wanted, but
after deleting the digit or trying to delete the entire record I
cannot get out of the field or close the form without the same message
popping up.


oops... we're crossing messages in the two different subthreads here! I just
posted how to do it with text fields. You're better off with numbers, just
leave out the ' marks in my other answer.

The BeforeInsert code should make it *unnecessary* to manually enter an ItemNo
value, since it will calculate one for you automatically. Can you just hit
EscEsc to cancel editing the record? Why the validation rule anyway - you
want to limit it to three items? Note that a validation rule of 4 permits
-12320185123 as a valid itemno... g



You are right about not having to enter a number in the ItemNo field.
I had been manually entering it myself, but when I started writing the
description of the ItemNo one was entered for me. Very good.

I've put the validation rule in there to liimit the entry to no more
than 3 items per E58No. However, it does not appear to be doing it's
job since the code was able to enter a 4th ItemNo. I will change it
to 1 Or 2 Or 3 to eliiminate the minus numbers, but I don't think that
will solve the *4th ItemNo* problem.