EasyCFM.COM ColdFusion Forums / MS Access Related Issues / Avoiding duplicate records in MS Access

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Avoiding duplicate records in MS Access

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

caldew
08-03-2010 @ 7:48 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 74
Joined: Aug 2005

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 74
Joined: Aug 2005

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 74
Joined: Aug 2005

Brilliant!  Some of us always look for the complicated route.

Thank you.

Ronnie


Website Designed and Developed by Pablo Varando.