can you post some other examples of *what* you want to achieve?
Main Topics
Browse All TopicsWhat i am trying to achieve is to count or increment new records being added to the Events Table based on activityidfk.
EVENT Table
EventID PK
ActivityIDFK FK
EventName
So when i add a new record to the event table for a new activityidfk it should be set to 1. When the same actiivityidfk is added to the table again, i need to perform some sort of count or increment on the event table for the specific activityidfk to set it to 2
The output i want to achieve is : -
Add Event
Please input 2nd activityID (or 1st, 3rd 4th etc.. based on how many same activityids there are in the table)
Input Event Name
ADD
Any otyher ideas on how to achieve this would be much appreciated
Best Regards
JT
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
sorry, in CF:
<cfif (actiID - (actID-1)) EQ 1 AND (actID - (actID-11)) NEQ 11>
<cfset str = "st">
<cfelseif (actID - (actID-2)) EQ 2 AND (actID - (actID-12)) NEQ 12>
<cfset str = "nd">
<cfelseif (actId - (actID-3)) EQ 3 AND (actID - (actID-13)) NEQ 13>
<cfset str = "rd">
<cfelse>
<cfset str = "st">
</cfif>
<cfoutput>Please input #actID##st# activity...</cfoutput>
Hi jturkington!
Maybe, this is what you are looking for :
<cfparam name="ActivityID" default="1"> <!--- I am assuming the ActivityIDFK data type is integer --->
<cfparam name="Counter" default="1"> <!--- Initialize value for Activity ID --->
<cfquery name="qGetTotal" datasource="DSN">
SELECT count(*) FROM tblEvent
WHERE ActivityIDFK = #ActivityID#
GROUP BY ActivityIDFK
</cfquery>
<cfif qGetTotal.recordcount>
<cfset Counter = qGetTotal.recordcount + 1> <!--- Add one for the next value --->
</cfif>
<cfswitch expression="#Right(Counter
<cfcase value="1">
<cfset Str = '#Counter#st'>
</cfcase>
<cfcase value="2">
<cfset Str = '#Counter#nd'>
</cfcase>
<cfcase value="3">
<cfset Str = '#Counter#rd'>
</cfcase>
<cfdefaultcase>
<cfset Str = '#Counter#th'>
</cfdefaultcase>
</cfswitch>
<cfoutput>
Please input #Str# activityID ...
</cfoutput>
Hope this helps you. Just try it.
Goodluck!
eNTRANCE2002 :-)
" <cfswitch expression="#Right(Counter
<cfcase value="1">
<cfset Str = '#Counter#st'>
</cfcase>
<cfcase value="2">
<cfset Str = '#Counter#nd'>
</cfcase>
<cfcase value="3">
<cfset Str = '#Counter#rd'>
</cfcase>
<cfdefaultcase>
<cfset Str = '#Counter#th'>
</cfdefaultcase>
</cfswitch> "
Does this take care of 21st, 22nd, 23rd, 31st, 32nd, ... etc. ?
Hi AndyBeckwith!
Yes. Of course, it takes care with that. That's why I'm using Right() function.
How about if you give it a try ??? Just copy and paste the below code.
:: SAMPLE CODE ::
<cfparam name="Counter" default="21">
<cfswitch expression="#Right(Counter
<cfcase value="1">
<cfset Str = '#Counter#st'>
</cfcase>
<cfcase value="2">
<cfset Str = '#Counter#nd'>
</cfcase>
<cfcase value="3">
<cfset Str = '#Counter#rd'>
</cfcase>
<cfdefaultcase>
<cfset Str = '#Counter#th'>
</cfdefaultcase>
</cfswitch>
<cfoutput>#Str#</cfoutput>
Hope this make sense.
Regards!
eNTRANCE2002 :-)
Business Accounts
Answer for Membership
by: Tacobell777Posted on 2005-03-17 at 16:06:26ID: 13570697
can you post some other examples of you want to achieve?