By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,191 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

Increase last number used by 1

P: 4
I have a list of order numbers and want to increase the last number used by 1 and store the latest number in a table.

Autonumber does not work for me as all the data is in a table already.

New to SQL so please help in non-technical (idiot way) explanation

thanks
Jul 26 '07 #1
Share this Question
Share on Google+
4 Replies


P: 65
Bit more explanation would be handy.

But I think what you want is to select the last number in your table and than increase it with one and then just write it back to the (or another) table.

There are sql functions wich let you return the first (or last if you change order) record from a table.

Greetz
Jul 26 '07 #2

P: 4
Bit more explanation would be handy.

But I think what you want is to select the last number in your table and than increase it with one and then just write it back to the (or another) table.

There are sql functions wich let you return the first (or last if you change order) record from a table.

Greetz

Sorry

im trying to create an order book that takes the last order number used and then creates a new order number ie. last order number plus 1 .

This saves the order with that order number in a table and on a new order gives the new order the next order number.

The order number up to now has been a manual system, look back to the last order and add 1.

However as the table is in use I cant put an auto number on it.

thanks for any help

Tony
Jul 26 '07 #3

P: 65
I have a list of order numbers and want to increase the last number used by 1 and store the latest number in a table.

Autonumber does not work for me as all the data is in a table already.

New to SQL so please help in non-technical (idiot way) explanation

thanks
You may try this:

Select MAX(field that has the number).....

This MAX will bring the last number in the order and then you can use the INSERT SQL command in order to insert it in another table.

abolos
Jul 26 '07 #4

missinglinq
Expert 2.5K+
P: 3,532
Expand|Select|Wrap|Line Numbers
  1. NewOrderNumber = DMax("[OrderNumberField]", "TableName") + 1
Welcome to TheScripts!

Linq ;0)>
Jul 26 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.