Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i create a selfnumbering column that numbers itself 1,2,3,1,2,3

Status
Not open for further replies.

pcrosby78

Technical User
Feb 6, 2002
11
US
i need a column similar to the autonumber column in a table. However i would like it to cycle through a certain amount of numbers and then begin repeating itself...

is this possible, if so how can i do it?

Thanks a lot
 
It can be done, but you will have to construct the "autonumbering" yourself.

Start with a new tabel (tabel1) with one filed and post, this will hold the curent number. Then whenever you add a post you just get the number from tabel1 and after that increamnt it with 1 (add 1 to the number).

Every time you have created a post with the "highest" number you reset the number in tabel1.

Markus Larsson
 
Larsson- great idea, just you have a lot of overhead by creating that secondary table just to hold onto one value in one record.

Storing a Custom Property in the database object would keep your database smaller (in more ways than one).

A custom database property doesn't care about Compact- tables love to be compacted- alot. Then again, if you're only modifying the field, and not deleting/adding new 1field records, then I don't believe it would grow. Still, a table's a table, and just the meta-data behind it can hold a significant amount (if you care about keeping things small).

For more information on creating a custom property, you should be able to use the example in Help, with a few minor modifications- use the index tab and type in "CreateProperty method", and check out the "EXAMPLE". You should be able to make a few changes to the given code, and throw it into a Module. Then just call your own custom setDBProperty and getDBProperty functions.

getDBProperty, when you're creating a new record. Increment it, compare the incremented number to the constraints of your upper limit and reset if neccissary, and then setDBProperty with the new number.

But- if you don't want to do too much VBA coding Larsson's idea is good too. If we all cared so much about keeping databases small, we'd all have chosen a different DBMS.

-MoGryph
[8O)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top