Howto not duplicate a field info

M

Marisa

Hello,
In a SQL record the PK and Identity is CustomerID. CustomerNumber is a 5
digit unique #.
How do I ensure that the user does not duplicate the CustomerNumber when
inputing it in a form?
TIA
M
ACC XP -> SQL2k
 
A

Al Campagna

Marisa,
In the table design for this table/form, make your CustomerID field...
INDEXED/Yes-NoDuplicates
On your form, on the AfterUpdate event of CustomerID, do a REFRESH. If
you entered a "dupe" ID, you'll get an error message indicating a duplicate
value.
If you don't do a AfterUpdate Refresh, you'll get the same error message,
but only when you finish filling out the entire form, and try to update the
table.
 
M

Marisa

Thanks Al but I got the CustomerID under control. My question was regarding
a different field: CustomerNumber or OrderNumber. The latter do not a key
assigned to them.
Rgs.
 
A

Al Campagna

Marisa,
If I understand correctly...
Any field that you don't want dupes in can be designated
Indexed/NoDuplicates in your table design. They don't have to be "primary
key" fields... since you already have one (CustomerID?).
A table can contain a PrimaryKey field (indexed/nodupes), and as many
Non-Primary (indexed/nodupes) as you need.
Simply put, a field doesn't have to be a PrimaryKey in order to prevent
dupes. Any field with Indexed/Nodupes will take care of that.
--
HTH...
Al Campagna
Candia Computer Consulting
Candia, NH
 
M

Marisa

Hello Al,
I created an IX_tblTableA, ColumnName 'CustomerNum' Order 'Ascending',
Create Unique, Index, Ignore Duplicated Key in the Primary File Group.
However, FormA still accepts duplicates. It shouldn't allow me to go on
inputing data in the form since CustomerNum is the first field which needs
to be populated. What am I missing?
 

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