Getting the next record number with ASP and Access?

Discussion in 'Software' started by RexNoctis, Jun 1, 2005.

  1. RexNoctis

    RexNoctis Corporal

    Hi all,

    Hoping someone can help me, I've built some call logging software for work using an Access database with a web front end. Everything is working perfectly apart from one thing. I'm using an 'autonumber' field within access that isn't generated until the data from the 'New Call' page is fed into the database. This is annoying as we have to keep the users on the phone until all the details have been entered, including our own thoughts on the call because I'm using the call id as a reference.

    Is there any way on persuading Access to tell me what the next call number will be? I can't just count the number of records because some records have been deleted so the call id number isn't in sync with the number of records.

    At the moment, I'm looking at a long winded way that writes a blank record into the database to get the refernce (call id) number, then rewriting it once all the details of the call have been inputted. This is working but results in 3 connections each time. I'm also worried, if two people tried to log a call at the same time, it's possible that the new details would be written into the wrong record number.

    I hope you see what I'm trying to do, any ideas to point me in the right direction would be helpful.

    Cheers.
     
  2. Kodo

    Kodo SNATCHSQUATCH

    Judging from your input process, your database model will need to incorporate a generated ID instead. I know of no such way to get the next value for the autonumber of a PK; aside from that, it may be risky. If someone else is inputting a record and he/she assumes the next value X and you assume the same, then the records are inaccurate.

    I would generate some sort of GUID for each record and refer to that instead.
     
  3. RexNoctis

    RexNoctis Corporal

    I think I'm going to have to do that, it's a shame because I've used the generated ID in a few places.

    The only other way I can think of to do it is to write a dummy record into the database, reserved for that user login, get the ID number, read the ID number back to the ASP page, then overwrite that record once all the data has been filled in.

    I can't see why that wouldn't work for this application, the maximum number of users is only likely to be around 10-15 at any one time, but it is a very inefficient way of doing it.

    I've got today, tomorrow and the weekend to play with it, supposed to start testing on Monday.

    Cheers Kodo
     
  4. Kodo

    Kodo SNATCHSQUATCH

    you could do that too, but, yes, it is very inefficient and could hinder performance. Afterall, it's an access db.. ;)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds