|
-
Dec 2nd, 2002, 03:21 PM
#1
Thread Starter
New Member
About duplicate values
Hi Guys,
I want to insert unique values and i am not using any primary key to my table.Before inserting my code it should check that it is inserting unique values and if it find any duplicate values then it should give me a message that like customer name already exists.
I want it without using primary key in my table.
Can any one help ......
Thanks in advance
-
Dec 2nd, 2002, 03:28 PM
#2
Addicted Member
This should work good for you:
VB Code:
SQL = "Select * from Customers where UserID='" & UserID & "'"
'recordset stuff here
If not rs.eof AND not rs.BOF then
'creation stuff
else
msgbox "Create", vbexclamation, "UserID alreayd taken"
end if
-
Dec 2nd, 2002, 04:07 PM
#3
Frenzied Member
Or this...
Code:
sql = "SELECT MAX(UserId) As 'max' FROM Customers"
if(IsNull(sql("max"))) then
nextid = 1000 'default value if no userid exists
else
nextid = sql("max") + 1
end if
"INSERT INTO Customers VALUES('" & nextid & "', '" & etc... & "')"
This is of course assuming that you are wanting some unique identifier for your records...
Last edited by Memnoch1207; Dec 2nd, 2002 at 04:10 PM.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|