Topic: Avoiding duplicate records in MS Access


caldew    -- 08-03-2010 @ 7:48 AM
  Hi

I need to create a simple voting slip.  One of the fields will be a Voting Slip Reference.  The database field is indexed (no duplicates).

Can you propose some simple code which, if a duplicate voting reference is detected, then I can call a clear error message.  No duplicate voting references are to be allowed.

Many thanks in anticipation

Ronnie


megan    -- 08-03-2010 @ 7:58 AM
  before you do your query to record the vote so a simple select query for the voting reference cfif one is detected then display your desired message cfelse post the vote to the database

hth ~megan

-------------------------------------------------------
"The chief cause of failure & unhappiness is trading what you want most for what you want now." ~Zig Ziglar


caldew    -- 08-03-2010 @ 8:37 AM
  Dear Megan

I am struggling with the syntax - this is what I have at the moment:

<cfquery name="rsFindduplicate" datasource="Dalston">
SELECT VotingSlipNumber
FROM Votes
WHERE VotingSlipNumber = #VotingSlipNumber#
</cfquery>



<cfif VotingSlipNumber EQUAL #VotingSlipNumber# >
<cflocation url="/DalstonEvents/Festival-2010/Voting/duplicateVote.cfm">

<cfelse>

.... INSERT query

</cfif>

VotingSlipNumber is the name of a field in my FORM.  How do I get that filed to relate to the database #VotingSlipNumber# and trigger the <cflocation ....>?

Many thanks for your help.

Ronnie


megan    -- 08-03-2010 @ 8:42 AM
  I would just check to see if it finds a record

<cfif rsFindduplicate.recordcount GTE 1 >
<cflocation url="/DalstonEvents/Festival-2010/Voting/duplicateVote.cfm">

<cfelse>

.... INSERT query

</cfif>

-------------------------------------------------------
"The chief cause of failure & unhappiness is trading what you want most for what you want now." ~Zig Ziglar


caldew    -- 08-03-2010 @ 8:47 AM
  Brilliant!  Some of us always look for the complicated route.

Thank you.

Ronnie


EasyCFM.COM ColdFusion Forums : http://archive.easycfm.com/forums
Topic: http://archive.easycfm.com/forums/viewmessages.cfm?Forum=30&Topic=14926