It is going to list them all based on your code: 1. Your query is returning ALL records 2. your displaying all OPTIONs in the SELECT dropdown but ONLY selecting the ones that was populated in the FORM.COMPANY_NUMBER field.
If you only want the SELECT dropdown to return the one in FORM.COMPANY_NUMBER then this would work: <cfloop query="qgetcompany"> <cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ COMPANY_Number)> <option value="#COMPANY_Number#" selected>[#COMPANY_Number#]</option> </cfif> </cfloop> *** Now this is true if FORM.COMPANY_NUMBER is a SINGLE VALUE not a list. If you FORM.COMPANY_NUMBER is a LIST, then it would be similar to: <cfif listfind(FORM.COMPANY_NUMBER, COMPANY_NUMBER)> <option>.... </cfif> On Wed, Sep 30, 2009 at 4:49 AM, Damo Drumm <damien.dr...@quinn-group.com>wrote: > > Hi, at the minute when i add a user to the database they can view all > companies on a list box. Im trying to reduce this so they will only have > access to what i enter in a table called USERSvCOMPANYACCESS, which has the > Users Key and the Company Number in it. Im using the below code, but its > displaying all company numbers I enter to that table, rather than just the > numbers I have chosen for that one user. > > Can anyone help me out here? > > <cfquery name="qgetcompany" datasource="#request.dsn#"> > select COMPANY_Number,USERS_Key > from USERSvCOMPANYACCESS > ORDER BY COMPANY_Number > </cfquery> > > <cfloop query="qgetcompany"> > <option value="#COMPANY_Number#" > <cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ > COMPANY_Number)>selected</cfif>> > [#COMPANY_Number#] > </option> > </cfloop> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326772 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4