I'm assuming it is following an insert since that's the subject line of this thread.
If you don't have cftransaction then another record could be created in between the two cfquerys and you could have the incorrect ID returned. Access isn't going to lock the database between the two requests waiting... - Calvin -----Original Message----- From: Ewok [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 01, 2005 11:04 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. > It absolutely isn't your only option. And if you do the below you need to > use cftransaction. I didn't say it was the only option known to man, I said it was ABOUT the only option for autonumbers. (I try to avoid autonumbers like the plague in a relational data structure) And why would you need cftransaction for that? It's a simple select. You think it should have cftransaction because it follows an insert? -----Original Message----- From: Calvin Ward [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 01, 2005 10:09 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. It absolutely isn't your only option. And if you do the below you need to use cftransaction. The best option, in my opinion, is to generate a UUID/GUID and use that instead of a database generated ID. That will work with every single database platform out there and will always be the correct ID. - Calvin -----Original Message----- From: Ewok [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 01, 2005 10:01 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. Wow, too much for so little, Just use Richard's method RUN YOUR INSERT QUERY Then directly after the insert get the records ID... <cfquery name="mid" datasource=""> SELECT MAX(TheID) as LatestID FROM TABLENAME </cfquery> The newest records ID from that table will now be in #mid.LatestID# Since you said "grab the id ( autonum, primary key)"... autonumber being an Access data type means the above is about your only option. Does @@identity even work in access? (or does anything else useful work in access for that matter) There's also no need to cflock the query from above that I can think of with an access data source. For the most part, access locks itself when it needs to. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.3 - Release Date: 1/31/2005 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192615 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

