How to ensure ...

Alix

Registered User.
Local time
Today, 02:40
Joined
Feb 3, 2003
Messages
32
I have a form with a field called Costumer Number i'm looking for a visual basic code (Or any MS Access properties) to help me make sure none of the customer number are repeated because they are unique.
I appreciate any help you offer me
 
One way is once the customer number is entered, but not updated, run a dcount using that number to see if it returns zero or not. You couls also make customer number a non-duplicated key field (or primary key) and let the DB tell you if it is duplicated.
 
If the number given to the customer is not defined somewhere else you could set the format of the field to autonumber in the table.
If you do this and the table already contains data, you will need to create a new table and transfer the data over, this will change the customer numbers you have already issued.

Another way is to change the definition in the field in the table to indexed yes(no duplicates). This is in the bottom grid in the table design view when the relavent field is selected.

In either case, if you change a field definition in a table, you need to remove the field from your form and replace it as changes to field definitions in a table are not automatically transfered to existing forms

Hope this helps

Sue
 
Thanks guys
But what you said is very professional i didnt understand is there any way to use VBA to do this (and easier)
 
In simpler terms.
1. Open the customer table in design view.
2. Click on the CustomerNumber to select it and the press the key icon in the tool bar. This will make the CustomerNumber the primary key of the table. Access will require that it be present and unique or it will refuse to save the current record.
 
Pat Hartman said:
In simpler terms.
1. Open the customer table in design view.
2. Click on the CustomerNumber to select it and the press the key icon in the tool bar. This will make the CustomerNumber the primary key of the table. Access will require that it be present and unique or it will refuse to save the current record.


Thanks Mate ;) I appreciate
Now how can i customise the error message:confused:
 

Users who are viewing this thread

Back
Top Bottom