Forums

This topic is locked

autonumber

Posted 27 Jan 2003 15:06:28
1
has voted
27 Jan 2003 15:06:28 wendy owens posted:
I have a form I am creating in Ultradev. I would like when the user clicks on add new record, for the Log No. to automatically populate with the next available number? How do I do this in Ultradev?
Any help is greatly appreciated.
Thanks

Replies

Replied 27 Jan 2003 16:55:45
27 Jan 2003 16:55:45 Dave Clarke replied:
If you are using access as your database, have a field in your table - "log No" and set it to autonumber, then when you add a record it will automatically put in the next available number.
The drawback to this however is that when you delete a record it doesnt recalculate the number... for example if you have records 1,2 & 3 and you delete record 2 you are left with 1 & 3, then if you add a new record it becomes 4 even tho you only have 3 records .. 1,3 & 4.

hope this helps

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 27 Jan 2003 18:40:08
27 Jan 2003 18:40:08 wendy owens replied:
Dave-
I am using an Oracle database to store my data. How would I set this up using the oracle database?? It is okay that it does not recalculate the number. Actually I don't want it to because the number I want to create is like a purchase order number and once a number has been used it shouldn't be used again.
Any suggestions?
Replied 28 Jan 2003 09:51:34
28 Jan 2003 09:51:34 Julio Taylor replied:
oracle SQL server (SQL*3.x) should have an auto_increment field or autonumber field which increments by itself.

if not, you can make a recordsert which returns the highest current id plus one, like so:
<pre id=code><font face=courier size=2 id=code>
SELECT SUM(record_id + 1) FROM table ORDER BY record_id DESC</font id=code></pre id=code>

this should give you the current highest record, plus one. you can include that top value in a hidden form in the field. This is ensure you are always giving the new record an "automatic" highest ID number!

------------------------
Julio

PHP | MySQL | UD4

ICQ: 19735247

Reply to this topic