Hey all. I need a little bit of help.

My ASP code submits to an access DB and into two tables. But one of my tables will not allow duplicate data. Hence this error

Microsoft JET Database Engine error '80040e21'

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.


This is my code. I can't figure out how to put a check on the code so it displays a freindly message.

Code:
<% @LANGUAGE = VBSCRIPT %>
<%
IF Session("blnValidComp") = False THEN             ' declare that current user is validated
Response.Redirect "index.asp"
ELSE ' If no session found then back to index page

'************************************************************
' This function takes a string and converts to Proper Case.
' Prototyped by: Brian Shamblen on 3/18/99
' This version by: Us... naturally!
'************************************************************
Function PCase(strInput)
	Dim iPosition  ' Our current position in the string (First character = 1)
	Dim iSpace     ' The position of the next space after our iPosition
	Dim strOutput  ' Our temporary string used to build the function's output

	' Set our position variable to the start of the string.
	iPosition = 1
	
	' We loop through the string checking for spaces.
	' If there are unhandled spaces left, we handle them...
	Do While InStr(iPosition, strInput, " ", 1) <> 0
		' To begin with, we find the position of the offending space.
		iSpace = InStr(iPosition, strInput, " ", 1)
		
		' We uppercase (and append to our output) the first character after
		' the space which was handled by the previous run through the loop.
		strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
		
		' We lowercase (and append to our output) the rest of the string
		' up to and including the current space.
		strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))

		' Note:
		' The above line is something you may wish to change to not convert
		' everything to lowercase.  Currently things like "McCarthy" end up
		' as "Mccarthy", but if you do change it, it won't fix things like
		' ALL CAPS.  I don't see an easy compromise so I simply did it the
		' way I'd expect it to work and the way the VB command
		' StrConv(string, vbProperCase) works.  Any other functionality is
		' left "as an exercise for the reader!"
		
		' Set our location to start looking for spaces to the
		' position immediately after the last space.
		iPosition = iSpace + 1
	Loop

	' Because we loop until there are no more spaces, it leaves us
	' with the last word uncapitalized so we handle that here.
	' This also takes care of capitalizing single word strings.
	' It's the same as the two lines inside the loop except the
	' second line LCase's to the end and not to the next space.
	strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
	strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))

	' That's it - Set our return value and exit
	PCase = strOutput
End Function

'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsAddInfo		'Holds the recordset for the new record to be added to the database
Dim strSQL			'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection


adoCon.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:ff.mdb;" ' Microsoft Access 2000



'Create an ADO recordset object
Set rsAddInfo = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database


strSQL = " My sql statment"


'Set the cursor type we are using so we can navigate through the recordset
rsAddInfo.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsAddInfo.LockType = 3

'Open the tblComments table using the SQL query held in the strSQL varaiable
rsAddInfo.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
rsAddInfo.AddNew

'Add a new record to the recordset

'Client Table first table

rsAddInfo.Fields("clUserName") = PCase(Request.Form("clUserName"))
rsAddInfo.Fields("clPW") = Request.Form("clPW")
rsAddInfo.Fields("clEmail") = Request.Form("clEmail")
rsAddInfo.Fields("clDateCreated") = FormatDateTime(now,2)
rsAddInfo.Fields("compEmployee") = Request.Form("compEmployee")
rsAddInfo.Fields("compTerms") = Request.Form("compTerms")
rsAddInfo.Fields("compHostIPAddress") = request.servervariables("REMOTE_ADDR")
rsAddInfo.Fields("compUserIPAddress") = request.servervariables("LOCAL_ADDR")

'Mailing List Second Table

rsAddInfo.Fields("Email") = Request.Form("clEmail")
rsAddInfo.Fields("emailFormat") = 0
rsAddInfo.Fields("isconfirmed")= True
rsAddInfo.Fields("mlConfirmDate") = FormatDateTime(now,2)
rsAddInfo.Fields("mlIpAddress") = request.servervariables("REMOTE_ADDR")

'Write the updated recordset to the database

rsAddInfo.Update

'Reset server objects
rsAddInfo.Close
Set rsAddInfo = Nothing
Set adoCon = Nothing

'Redirect
'Response.Redirect ""
%>