- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI have an issue with my next record code in Coldfusion. I have a database with electronics information in it at several installations...so installation 1 might have 10 pieces of electronics. I distinguish the different pieces by what building they're located in. So I have a page that allows me to search by installation, and then it returns a list of all of the electronics at that installation. I have an edit link where I can open a specific record and I pass the installation name and ther building number thru the url. My problem is that I want to have a next/previous button at the top of the edit page that opens when I select the edit button. If I select the edit button on a building number in the middle of the installation list, it automatically opens the first record of the query, not the record I selected in the list. If I add a where clause in my query to include the building number, then I get the right record, but then only one record shows up and therefore there is no next/previous button to get to the next record in the query. Can I use the next/previous while still starting in the middle of a recordset?? Below is my code....any help would be greatly appreciated...I've been fighting this for some time now......
editDSN -----------------------
<CFSET EditMode=IsDefined("URL.IN
<CFSET EditMode=IsDefined("URL.BU
<CFIF EditMode>
<cfset SESSION.urlpass.INSTALLATI
<cfset SESSION.urlpass.BUILDING = URL.BUILDING>
<CFSET ORGANIZATION=Trim(DSNedit.
<CFSET STREET_ADDRESS=Trim(DSNedi
<CFSET BLDGNO=Trim(DSNedit.BLDGNO
<CFSET CITY=Trim(DSNedit.CITY)>
<CFSET STATE=Trim(DSNedit.STATE)>
<CFSET ZIP_CODE=Trim(DSNedit.ZIP_
<CFSET RCIO_REGION=Trim(DSNedit.R
<CFSET FormTitle="Update Installation">
<CFSET ButtonText="Update">
<CFELSE>
<CFSET ORGANIZATION="">
<CFSET STREET_ADDRESS="">
<CFSET BLDGNO="">
<CFSET CITY="">
<CFSET STATE="">
<CFSET ZIP_CODE="">
<CFSET RCIO_REGION="">
<CFSET FormTitle="Add an Installation">
<CFSET ButtonText="Insert">
</CFIF>
<cfquery name="IDDB" datasource="DSNSwitch_PM">
SELECT DISTINCT ORGANIZATION
FROM DSNSWITCH_PM.POC_INFORMATI
</cfquery>
<cfquery name="Addr1" datasource="DSNSwitch_PM">
SELECT DISTINCT STREET_ADDRESS
FROM DSNSWITCH_PM.POC_INFORMATI
</cfquery>
<cfquery name="Cityfield" datasource="DSNSwitch_PM">
SELECT DISTINCT CITY
FROM DSNSWITCH_PM.POC_INFORMATI
</cfquery>
<cfquery name="Statefield" datasource="DSNSwitch_PM">
SELECT DISTINCT STATE
FROM DSNSWITCH_PM.POC_INFORMATI
</cfquery>
<cfquery name="Zipfield" datasource="DSNSwitch_PM">
SELECT DISTINCT ZIP_CODE
FROM DSNSWITCH_PM.POC_INFORMATI
</cfquery>
<cfquery name="Regionfield" datasource="DSNSwitch_PM">
SELECT DISTINCT RCIO_REGION
FROM DSNSWITCH_PM.POC_INFORMATI
</cfquery>
<CFQUERY DATASOURCE="DSNSwitch_PM" NAME="GetCount">
SELECT *
FROM DSNSWITCH_PM.POC_INFORMATI
WHERE POC_INFORMATION.ORGANIZATI
AND POC_INFORMATION.BLDGNO='#U
</CFQUERY>
<CFSET recordperpage = 1>
<CFPARAM NAME="URL.startrow" default="1" type="numeric">
<CFSET totalRows = GetCount.recordCount>
<CFSET endRow = min(URL.startrow + recordperpage -1, totalRows)>
<CFSET startRowNext = endRow + 1>
<CFSET startRowBack = URL.startRow - recordperpage>
<html>
<head>
<title>Untitled Document</title>
<body>
<cfform name="InstallationForm" action="LMRUpdate.cfm" method="post">
<table width="800"><td>
<h3><span class="style1 style7">Information for</span> <CFOUTPUT><span class="style1 style2">#ORGANIZATION#</sp
</CFOUTPUT></td>
<tr><td><cfoutput>
<span class="style10">Displaying
<span class="style10 style7">of</span> <span class="style7 style1"><strong><span class="style2">#totalRows#
</cfoutput>
<cfinclude template="NextNIncludeBack
</table>
<cfloop query="GetCount" startRow="#startRow#" endRow="#endRow#">
---- BUNCH OF FORM FIELDS HERE -----
</cfloop>
</body>
</CFFORM>
</html>
Then my nextininclude template --------------------
<cfset SESSION.urlpass.INSTALLATI
<cfset SESSION.urlpass.BUILDING = URL.BUILDING>
<cfoutput>
<cfif startRowBack gt 0>
<a href="#CGI.script_name#?AR
<img src="../../Images/BrowseBa
</cfif>
<cfif startRowNext lte totalRows>
<a href="#CGI.script_name#?AR
<img src="../../Images/BrowseNe
</cfif>
</cfoutput>
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.
Business Accounts
Answer for Membership
by: stu215Posted on 2007-03-14 at 09:28:33ID: 18719803
Hmm, not quite sure I understand but thought i'd try helpin ya out...
1. When you first search, it returns a list of the different installations.
2. Selecting an installation returns all the electronics in that building with an edit button next to each.
3. You select an electronic to edit and on this page you want to be able to scroll + or - through the list on the previous page?
-- Rather than passing all these variables in the URL why not use a form?
( it looks cleaner and can be easier to process depending on what your doing. )
------------ Possible solution 1 -----------
Pass a list of ALL the electronics at an installation to the EDIT page and store them in a javascript array
which you could use to move forwards and backwards.
------------ Possible solution 2 -----------
Re #3 :: if you were to add a field to the table that ( creates the list of electronics ) called "myIndex" set the type to INT and turn autoincrement on it will add a number to every record in the table which you should be able to access on the edit page if you pass it from the installation page.
-- If you delete a record ( electronic ) it could create a gap in the sequence though.. :-\