473,386 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

conditional autonumber ID's

Does anyone know how to create autonumbers dependent on a chosen catagory?

I'll explain the scenario.....

I am working on simple a reel database for a post-production company.

The required fields are:

Client
Title/Description
Catagory
Genre
Reel No.

Catagories & Genres will be updated from time to time & the 'Reel No.' requires a prefix dependant on catagory.. thus I have created the folowing tables:

REELS
Reel_ID (PK autonumber)
Client
Description
Catagory_Name (FK)
Genre (FK)
Reel_Number

CATAGORIES
Catagory_Name
Prefix

GENRES
Genre

Now here is where I get stuck... the 'Reel No.' needs to have a unique number by catagory not by reel.... ie: Music Videos would be 'MV001 - MV999' and seperatly Adverts would be 'AD001-999'.... I have tried some workarounds in VB on the forms, but these create as many problems as they solve!..... also has to be in daily use by it none literate... any clues??
Jul 4 '06 #1
2 5015
zzqxxq
28
Unfortunately, AUTOnumbers are just that automatically created numbers - ideally these numbers were never intended to be used for any purpose other than to provide a unique identifier for a particular record so there is no simple mechanism to alter their format. If you need a particular format you therefore must create it and put it into a field that is not defined as an autonumber field but as a text field (your codes are alphanumeric).

This involves creating a global static variable (for each category) that has to initially set to 1 and increased by one each time a new record is added to the category in question. As the record is created you will have to prefix the number with the category abbreviation. In addition, because your format requires a 3 digit number, the first 99 records will have to be formatted to include one or two (for the 1st 10 records) leading zeros. This number would be created / formatted when the user selects the category therefore the code goes in the exit function of the combo box (I'm guessing) you have for the genre field. There really is no other way I know of to do this.

Write back if you need help with the code. Of course the easy to cheat at this would be to keep a paper record of the last number used in each category add one to it in your head, write it on the paper then just enter it into a text field - but that sort of defeats the purpose of the db dosen't it
Jul 13 '06 #2
randomDude
1 Bit
Hi Sir zzqxxq, I have the same question. I really hope you can help us with the code.
Jul 7 '21 #3

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

Similar topics

3
by: Ilan Sebba | last post by:
I have a 'supertype' table with only one field: autonumber. Call this table the 'parent' table. There are two subtypes, 'androids' and 'martians'. Martian have only one thing in common: they give...
2
by: Ed Havelaar | last post by:
Hi, Hope someone can help. Here's the scenario: I have two MSAccess tables MainTab and SubTab. MainTab has an autonumber 'id' column as primary key. Subtab has this id column as a foreign...
35
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
1
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
6
by: HS1 | last post by:
Hello I have a table in Access Database. This table has a AutoNumber field. I use a DataGrid to show that table When I insert a new record in for this table using a DataGrid, there is a...
1
by: jason.teen | last post by:
Hi, I have this scenario - 2 separate db's (filename = dbOne.mdb" and "dbTwo.mdb") both with a table called tblMapped in it dbOne.tblMapped looks like:...
1
by: mswhiteside | last post by:
Hello All, I have a query that i need to have ID's that start over on certain records in the Table like below Field 1---Conditional AutoNumber IRM-------------1 1-----------------2...
6
by: Wayne | last post by:
I'm using the following SQL statement to find the next highest autonumber value in a table where "CDUGActID is the autonumber field in the "CDUGActuals" table: SELECT CDUGActuals.CDUGActID,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.