CFABORT is not stopping my cfm page.

I am trying to use <CFABORT> to exit a cf page when the CFQUERY in the page finds no records.
I want to do this so the CFLOOP after the CFQUERY does not continue.

The problem is that the page continues to process.  I need the  to stop the process and give the error message to the user.
Here is the part of my code that is giving the problem.
Please help!

///////////////////////////////////////////////////////////////////////////////////////////////////////////
<cfif division is "A">
<cfquery name="Query_AB" datasource="retail_trs">
select INumber,IcodeNumber,spm_subline,rel_month,(Total-Actuals) as Hours
From A
where INumber like '%-A' and inPace = 'Y'
order by rel_month
 </cfquery>
<cfif Query_AB.RecordCount IS 0>
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

<cfloop query="Query_AB">
<cfif form.total_hours GT hours>
<cfquery  datasource="retail_trs">
INSERT INTO C (Hours,INumber,ICodeNumber,Curdate, Emp,rel_month,spm_subline)
VALUES (#int(hours)#,'#INumber#','#IcodeNumber#','#dateformat(Now(),"DD-MMM-YYYY")#','#form.employee#','#rel_month#','#spm_subline#')
</cfquery>
</cfloop>
///////////////////////////////////////////////////////////////////////////////////////////////////////////
LVL 1
g118481Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tim_csCommented:
Don't know if this will solve the problem or not but try and change your cfif to one of these.

<cfif Query_AB.RecordCount IS "0">
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

or

<cfif Query_AB.RecordCount EQ 0>
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rob_lorentzCommented:
that should work.

try this...
<cfif division is "A">
<cfquery name="Query_AB" datasource="retail_trs">
select INumber,IcodeNumber,spm_subline,rel_month,(Total-Actuals) as Hours
From A
where INumber like '%-A' and inPace = 'Y'
order by rel_month
 </cfquery>
<cfdump var="#query_AB#">
<cfabort>
<cfif Query_AB.RecordCount IS 0>
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

This will tell us if the if is failing or the cfabort inside the if.
0
JeffHowdenCommented:
Maybe try a different approach:

<cfif NOT Query_AB.recordcount>
  <cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
<cfelse>
  ....
</cfif>
0
Mr_NilCommented:
If you follow Jeff's advice you should be able to do away with the cfabort all together, because there should be nothing after the end of the cfif and the code that would run if you do get a recordcount will be tucked safely away in the cfelse part of the cfif.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.