When I created the field up I did set the Index to Yes (No duplicates).
Unfortunately it didn't alert about the duplicate number until the form was
completely filled out and I know that the end users are going to be
aggravated. Maybe my first question should have been - is there a way to get
the system check for duplicates when the user tabs out of the phone number
field.
Wayne - please forgive my ignorance. I tried to paste the code that you
wrote into the VB code editor but I kept getting errors. I'm sure that it's
something that I'm doing or not doing.
If I could borrow your expertise one more time. Below are the specifics
concerning my database.
Business Phone = field name on form
frm Contacts = form name
Business Phone = field in table containing data
tbl Contacts
Record ID = not sure if this is needed but this is unique to each record in
the database
Below is what I entered into the VB Editor window:
Private Sub Business_Phone_AfterUpdate()
If ((DLookup("Business_Phone", "tbl_Contacts", "Business_Phone ='" &
frm Contacts!Business_Phone & "' "))) Then
Beep
MsgBox "This number is already in use", vbOKOnly, "Telephone number "
checker ""
End If
End Sub
Thanks in advance for your help.
Brian...
Wayne-I-M said:
Hi
Allen's answer is the simplest LoL
But just in case you want to - ?? (there was a typo in my last - just
checked this and it's OK)
Private Sub NumberConmtrol_AfterUpdate()
If ((DLookup("[PrimaryFieldID]", "[TableName]", "[NumberField] ='" &
Form!NumberControl & "' "))) Then
Beep
MsgBox "This number is already in use", vbOKOnly, "Telephone number
checker"
End If
End Sub
Notes - you will need to alter these.
Number field = the field containing the number in the "table"
PrimaryFieldID = The ID Primary field of the record containg the number in
the "table"
NumberControl = the field containing the number in the "form"
You must leave all the '" in place - just change the text.
Take the Beep off in you don't want it.
Hope this helps
--
Wayne
Manchester, England.
:
Open your table in design view.
Select the Phone Number field.
In the lower pane of table design, set:
Indexed: Yes (No Duplicates)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
I have a database that includes a phone number field. I want to prevent a
user from creating a new record that contains a phone number that is
currently in a record that exists in the database.
I am using a form for data entry into the table. Somehow I'd like for
there
to be a check to see if the phone number typed into the phone number field
to
be checked against existing phone numbers in the database.
I've researched various sources but haven't been able to find the
solution.
I'm not familiar with VB so any replies that suggest using that will
probably
not work for me. Sorry, just being honest.
Thanks in advance for any help.
Brian...