Inserting a Record with a AutoNumber

They have: 25 posts

Joined: Aug 2001

I have a couple of pages linked to an Access database and I want to create a page that will add a new record, easy. But I also want that page to display the recordID for the new record as soon as the user opens the page. I know I can grab all the user input and then add the record and then display the data but that isn't good enough I need to desplay the record ID up front.
Anyone now an elegant solution for me?

Thanks

Paul

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Access is not going to be very reliable for this, for an example check out the following link:

http://www.aspfaq.com/faq/faqShow.asp?fid=74

openmind's picture

He has: 945 posts

Joined: Aug 2001

The ColdFusion method....

Lets call your AutoNumber Field RecordID for arguments sake.

Write a query to get the max No. of records:

<cfquery datasource="YourDSN" name="MaxRecord">
SELECT Max(RecordID) as MaxRecord
FROM YourTableName
</cfquery>
'

Now display the last record...

<cfoutput query="MaxRecord>
  #MaxRecord#
</cfoutput>
'

This will disply the last record ID...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.