Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for duplication record

Status
Not open for further replies.

ptuck

MIS
Aug 8, 2003
130
US
This is what I am trying to do:

User enters their data on the date entry page and clicks the submit button. Next I want to query the database (access db) and see if a record already exists and if not then insert the new data. If the record for this person already exists, then redirect to error page for a few seconds then redirect to entry page.

I was thinking I would query the database and populate a recordset. If the recordset is empty then continue to the insert statement, if not then go to error page. How can I tell if the recordset is empty? Is this the best way?

Thanks for your help,
Paul
 
ptuck,

What you have outlined above should be sufficient. Querying the database to determine if the record already exists and, if not, then inserting it should work just fine. One easy (and common) way to check if your recordset comes back empty would be as follows:
Code:
<%
if rs.BOF and rs.EOF then
  'recordset is empty
else
  'recordset has at least one record
end if %>
Hope this answers your question.

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
I would open the database run the query then use:

if rs.eof then

rs.addnew

etc etc

end if


hth

simon
 
simonchristieis,
I have nevered used your option, but have seen it in a couple of places on this site. Could you provide more sample code and maybe explain the process a little more?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top