Validate data entry

B

Barb Miles

I have a text field in a table.
I want to validate new records so no text entry can be entered more than once.

The name of the text field is [Dealer]

Will it work to set up a Validation Rule?

How would I set this up?
 
R

Rick Brandt

Barb Miles said:
I have a text field in a table.
I want to validate new records so no text entry can be entered more than once.

The name of the text field is [Dealer]

Will it work to set up a Validation Rule?

How would I set this up?

Just set the Indexed property to "Yes (No Duplicates)" or make it the Primary
Key of the table if that is appropriate.
 
B

Barb Miles

We cannot set the Indexed property to Yes (No Duplicates) in this case or set
it as the Primary Key.

Can anyone give me the steps to set up a Validation Rule?
--
Barb


Rick Brandt said:
Barb Miles said:
I have a text field in a table.
I want to validate new records so no text entry can be entered more than once.

The name of the text field is [Dealer]

Will it work to set up a Validation Rule?

How would I set this up?

Just set the Indexed property to "Yes (No Duplicates)" or make it the Primary
Key of the table if that is appropriate.
 
R

Rick Brandt

Barb Miles said:
We cannot set the Indexed property to Yes (No Duplicates) in this case or set
it as the Primary Key.

Can anyone give me the steps to set up a Validation Rule?

You cannot do what you want with a Validation Rule defined in the table. You
could however use a Validation Rule on the control bound to this field on a
form. From the help file...

For controls, you can set the ValidationRule property to any valid expression.
For field and record validation rules, the expression can't contain user-defined
functions, domain aggregate or aggregate functions, the CurrentUser or Eval
function, or references to forms, queries, or tables. In addition, field
validation rules can't contain references to other fields.

If I were doing this on a form I would prefer to use the BeforeUpdate event with
some VBA code as I would have more control and flexibility in writing the
validation test. In a validation rule I assume you would have to use DCount()
to return the number of rows with the same value and test that it returns zero.

Can you explain why a unique index cannot be used?
 

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