avoid adding duplicate records in access/asp
Hi guys,
Here are my existing asp pages,
1.profile_add_office.asp
<form method="POST" action="PROFILE_ADD_ac.asp" name="form" onSubmit="return validateForm(this)">
<input type="text" name="BldgnameNew" size="50">
'etc.
2.profile_add_ac.asp
BldgnameNew= ChkString(Request.Form("BldgnameNew"))
'etc.
sql_insert = "insert into TblSubgroup (Bldgname, cgroup, Datebuilt, GFA, GLA) values ('" & BldgnameNew & "','" & group & "', '" & Datebuilt & "', '" & GFA & "', '" & GLA & "', )"
I just want to ask how is it done in asp/access, to avoid duplicate or identical records to be added by the user in the database.
Here's exactly the scenario and what I want to happen with the application, I have a table in Access that holds records such as Bldgname, Datebuilt, Gross Floor Area (GFA), etc. Users can add new records (Bldgname, Datebuilt, GFA, etc.) but if the user enters the exact Building Name (Bldgname) that already exists in the database (i.e. Tower One - tower one), he will be prompted not to continue either by another asp page or a pop-up window, "Another record of the same building name already exists in our database, thank you.".
Can this be done by adding a condition in my sql insert statement such as...
sql_insert = "insert into TblSubgroup (Bldgname, cgroup, Datebuilt, GFA, GLA) "
sql_insert = sql_insert & " values ('" & BldgnameNew & "','" & group & "', '" & Datebuilt & "', '" & GFA & "', '" & GLA & "', ) "
sql_insert = sql_insert & " where Bldgname <> (Request.Form("BldgnameNew"))"
I'm getting errors when I tried the sql_insert above...
Expected end of statement in sql_insert.
Any other ways? Thanks a lot in advance to all of you :)
|