I 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
STALLATION
_NAME")>
<CFSET EditMode=IsDefined("URL.BU
ILDING")>
<CFIF EditMode>
<cfset SESSION.urlpass.INSTALLATI
ON_NAME = URL.INSTALLATION_NAME>
<cfset SESSION.urlpass.BUILDING = URL.BUILDING>
<CFSET ORGANIZATION=Trim(DSNedit.
ORGANIZATI
ON)>
<CFSET STREET_ADDRESS=Trim(DSNedi
t.STREET_A
DDRESS)>
<CFSET BLDGNO=Trim(DSNedit.BLDGNO
)>
<CFSET CITY=Trim(DSNedit.CITY)>
<CFSET STATE=Trim(DSNedit.STATE)>
<CFSET ZIP_CODE=Trim(DSNedit.ZIP_
CODE)>
<CFSET RCIO_REGION=Trim(DSNedit.R
CIO_REGION
)>
<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
ON
</cfquery>
<cfquery name="Addr1" datasource="DSNSwitch_PM">
SELECT DISTINCT STREET_ADDRESS
FROM DSNSWITCH_PM.POC_INFORMATI
ON
</cfquery>
<cfquery name="Cityfield" datasource="DSNSwitch_PM">
SELECT DISTINCT CITY
FROM DSNSWITCH_PM.POC_INFORMATI
ON
</cfquery>
<cfquery name="Statefield" datasource="DSNSwitch_PM">
SELECT DISTINCT STATE
FROM DSNSWITCH_PM.POC_INFORMATI
ON
</cfquery>
<cfquery name="Zipfield" datasource="DSNSwitch_PM">
SELECT DISTINCT ZIP_CODE
FROM DSNSWITCH_PM.POC_INFORMATI
ON
</cfquery>
<cfquery name="Regionfield" datasource="DSNSwitch_PM">
SELECT DISTINCT RCIO_REGION
FROM DSNSWITCH_PM.POC_INFORMATI
ON
</cfquery>
<CFQUERY DATASOURCE="DSNSwitch_PM" NAME="GetCount">
SELECT *
FROM DSNSWITCH_PM.POC_INFORMATI
ON
WHERE POC_INFORMATION.ORGANIZATI
ON='#URL.I
NSTALLATIO
N_NAME#'
AND POC_INFORMATION.BLDGNO='#U
RL.BUILDIN
G#'
</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
an>;<BR>
</CFOUTPUT></td>
<tr><td><cfoutput>
<span class="style10">Displaying
</span> <span class="style7 style1 style8"><strong>#URL.start
Row#</stro
ng></span>
<span class="style10 style7">of</span> <span class="style7 style1"><strong><span class="style2">#totalRows#
</span></s
trong></sp
an> <span class="style10">Record(s)<
/span>
</cfoutput>
<cfinclude template="NextNIncludeBack
Next1.cfm"
></td></tr
>
</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
ON_NAME = URL.INSTALLATION_NAME>
<cfset SESSION.urlpass.BUILDING = URL.BUILDING>
<cfoutput>
<cfif startRowBack gt 0>
<a href="#CGI.script_name#?AR
MY_INSTALL
ATION_NAME
=#SESSION.
urlpass.IN
STALLATION
_NAME#&BUI
LDING=#SES
SION.urlpa
ss.BUILDIN
G#&startRo
w=#startRo
wBack#">
<img src="../../Images/BrowseBa
ck.gif" width="40" height="16" alt="Previous Record" border="0" /></a>
</cfif>
<cfif startRowNext lte totalRows>
<a href="#CGI.script_name#?AR
MY_INSTALL
ATION_NAME
=#SESSION.
urlpass.IN
STALLATION
_NAME#&BUI
LDING=#SES
SION.urlpa
ss.BUILDIN
G#&startRo
w=#startRo
wNext#">
<img src="../../Images/BrowseNe
xt.gif" width="40" height="16" alt="Next Record" border="0" /></a>
</cfif>
</cfoutput>