okay, then you need a programmatically generated value. you can use a simple
imcrementing code, such as
Nz(DMax("ProductField", "MyTable", "Destination = 8781 OR Destination =
8936"), 0) + 1
which searches all the records in the table with either of those two
destinations, finds the highest value in the product field, and then adds 1
to it.
if you have multiple users entering data in this table at the same time,
then you're going to have duplicate numbers generated at some point - almost
guaranteed. assuming that there should never be a duplicate value in this
field, the first thing to do is set the field's Indexed Property to No
Duplicates, at the table level. in the data entry form, set the code that
generates the ID in the form's BeforeUpdate event. you may still get a
"duplicate value" error at the form level, so you also need to trap that
error, and re-run the ID-generating code until the system succeeds in saving
the record with a unique ID.
btw, you should remove the
Else
Me.BOL_ = ""
from your code. the system may not consider multiple records with a
zero-length string value as a violation of the unique index, but it's still
generally not a good idea to store a zero-length string in a text field. a
zero-length string value is NOT the same as a Null value, but you can't tell
the difference with the naked eye, and you have to write queries and
expressions very precisely to make sure they handle the two different values
exactly the way you expect them to.
hth