469,636 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

NO duplicate entries

Quick Question. I gotta a database with fields firstname, lastname, and hobby, etc. I dont want to allow duplicate entries for the name. For instance....no john smith twice....but there can be a repeated john. Well i created a multi-field index and that is fine....the problem is that my form is very long....there is lots of data to enter and the user could very well end up adding all this data then going to close it and find out it wont work. I want the user to know that it is a duplicate name right after they enter the first and last name. Can you help me with this. I tried to put
DoCmd.RunCommand acCmdSaveRecord
in the after update field for first and last name. But it is giving me a runtime error. Can anyone help me? I know my code must be wrong.
Thanks in advance
Mar 27 '06 #1
1 1718
CaptainD
135 100+
Looks like you're using MS Access (You should give details such as program, language, code snippets if available etc. when posting a question) Try creating a Query:
Expand|Select|Wrap|Line Numbers
  1.  SELECT COUNT(*) FROM YourTable WHERE FirstName = Trim(txtFirstName.Text) AND LastName = trim(LastName) 
Then once the person exits the txtFirstName or txtLastName have your form run a Function that runs the Query and returns the number of records. (0 for none, meaning no match.) Then go through an IF THEN to give notice of a duplicate entry.
Mar 27 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Gary Lundquest | last post: by
1 post views Thread by Gary Lundquest | last post: by
1 post views Thread by marx | last post: by
3 posts views Thread by andreas.maurer1971 | last post: by
4 posts views Thread by sri2097 | last post: by
5 posts views Thread by Chris Lasher | last post: by
6 posts views Thread by teser3 | last post: by
7 posts views Thread by php_mysql_beginer911 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.