I'm having trouble seeing why you need a loop for this?? Can you explain? >From your description I would think you'd follow these steps (conditional statements and not loops):
1) set your random number (as you have) 2) run a query to see if that number is used in either table (simple SELECT statement) 3) IF there is a recordcount to the above query then it's in use - do whatever you need to do to handle this. IF NO recordcount then use it as your new job number to create the record(s) you need. HTH Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] --------------------------------------------------------- Macromedia Associate Partner www.macromedia.com --------------------------------------------------------- Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Thursday, March 20, 2003 9:55 AM Subject: Unique random number? > Need to set a job number to a unique number, based of creating a number > using the RandRange function, but then I need to take that number and > bounce it off two access tables (called openjobs & closejobs) to see if > that random number is already used, then loop back if it is to start over, > but if it isn't, then use it to create a new record in openjobs table. > > What I don't know how to do is the loop structure if the number already > exists on one of the two tables. > > Could someone direct me in how the code would look starting with this CFSET > statement? > > <CFSET job_number = RandRange(1, 100000)> > > ...and as always, thanks in advance! > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4