error message if multiple index is violated

sprite66

New Member
Joined
Aug 4, 2006
Messages
9
Hi,

I'm creating a contact information database. I have created a multiple field index for first and last name and I would like an error message to appear as soon as these two fields are filled if the contact is already in the database. Is there any way to create a validation rule for two fields?

Any suggestions about how to get an error message to display "Contact already in database" would be greatly appreciated.

Thanks in advance :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
In the AfterUpdate event of both fields have code that will call a CheckForDup() function. By putting it into both fields, any changes will always be checked.

The CheckForDup() function would then do a DLookup to see if the name is already present.
Code:
ReturnValue = DLookup("RecordID", "tblContactInformation", "FirstName='" & Me.FirstName & "' AND LastName= '" & Me.LastName)
This line of code will put the RecordID into the ReturnValue variable if there is a record that matches.

HTH,
 
Upvote 0
Not sure what you're using this database for but one thing to consider is that it's not that uncommon to have different contacts with the same name.
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top