I Need help desperately...

france

Member
Joined
Feb 17, 2005
Messages
17
Location
CA
Programming Experience
1-3
Subject Override: Finding next autoincrement value in Access Database

I only have a few hours left before I pass this project and Im having a hard time.. pls pls pls help me..

Heres the problem.. I have an Access database that contains a table named Customer.. now, as an attribute of that table, I have a customer ID that is an autonumber.. When I add a customer in my windows application at run time I want the system to display the customer number for that new customer..

Since I havent inserted a customer yet.. there is no row to select.. is it possible to get the next autonumber?

I tried DataTable.Row.Count and then go to the dataTable (count-1)(0) to get the last customer ID autonumber then plus 1 for the next new customer.. however it failed when I deleted a customer because when I created a new customer the customer ID it displayed is the last row of the table + 1 which is not the right autonumber of the new customer..

I need help asap pls pls pls pls.... this will really mean soooo much to me.. thank you so much.. and God bless all of you!
 
Last edited by a moderator:
'Allows us to retrive the last entry into the Database
'This last entry will be the reference number
Dim sql As String = "SELECT TOP 1 Id FROM Details ORDER BY Id DESC"
 
thanks for replying

thanks for replying.. but I dont the snippet of code you wrote...

do you mean I need a query in order to get the next autonumber?

and can you explain the code your wrote a bit please? thank u so much..
 
Basically this bit of code gets the last record inserted into the database
VB.NET:
Dim sql As String = "SELECT TOP 1 Id FROM Details ORDER BY Id DESC"
 
Back
Top