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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query output problem

Status
Not open for further replies.

nohandlesleft254

IS-IT--Management
Apr 19, 2006
58
GB
Hi,

I have a bit of code that adds and removes lines in a query. The lines represent items that can either be individual items or parts of a multi-part item. The field that shows this difference is called PlanRef.

Plan Ref Item Code
1 BU40
2 BU80
3 D3DP60
3 BGE
3 NID
4 BU80

etc
My problem occurs when someone deletes an item that comes before on of the multi-part items. E.G if someone deleted the first item 'BU40', the resulting query would be this:

Plan Ref Item Code
1 BU80
2 D3DP60
3 BGE
3 NID
4 BU80

The query gets renumbered every time the page loads but obviously should be re-numbering as per lines with matching PlanRefs... any ideas? My re-number code is below...

<!--- Re-Sequence each row --->
<cfset NewPlanref = 0>
<cfoutput query="Session.NewQuoteItems" group="PlanRef">
<cfif NewPlanref gt 0>
<cfset NewPlanref = NewPlanref +1>
<cfelse>
<cfset NewPlanref = 1>
</cfif>
<cfoutput>
<cfset QuerySetCell(Session.NewQuoteItems, "PlanRef", NewPlanref, Session.NewQuoteItems.CurrentRow)>
</cfoutput>
</cfoutput>
 
I don't quite follow you there.. what are you expecting for output?
 
Hi,

Thanks for your response. Sorry if i made a meal of it. What the client needs is rows of items, associated to other items by this planref field. So some items may be single items and have individual planref no's, and other may have the same planref no's as several other items. The problem cam when some one deleted an item (say planref no 2) - i then need to renumber all the products from 1- whatever. When this output got to a multi-part item (several rows with the same PlanRef) i allways gave the first item a different number from the rest. If this still doesnt make sense - im sorry! I have attached the code i ended up using below.

Thanks again.

<cfset NewPlanRef = 0>
<cfset PrevOldPlanRef = 0>
<cfloop query="Session.NewQuoteItems">
<cfif PlanRef eq PrevOldPlanRef>
<cfset NewPlanRef = NewPlanRef>
<cfset PrevOldPlanRef = PlanRef>
<cfset QuerySetCell(Session.NewQuoteItems, "PlanRef", NewPlanRef, Session.NewQuoteItems.CurrentRow)>
<cfelse>
<cfset NewPlanRef = NewPlanRef+1>
<cfset PrevOldPlanRef = PlanRef>
<cfset QuerySetCell(Session.NewQuoteItems, "PlanRef", NewPlanRef, Session.NewQuoteItems.CurrentRow)>
</cfif>
</cfloop>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top