473,414 Members | 2,019 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,414 software developers and data experts.

Access VB Code to assign AutoNumbering Field to a Table.

23
Does anybody know a VB code that would populate the "AutoNumber" field each time it is run for my "Transpo" table in the manner depicted below?

I need the AutoNumber field to reset at the begining of each new group under the "Maker" field. It should be in ascending order by Type.Transpo, Maker.Transpo, Model.Transpo
  • Table: Transpo
  • Field1: Type
  • Field2: AutoNumber
  • Field3: Maker
  • Field4: Model

Type___AutoNumber______Maker______Model
Car_________1__________ Chevy______Beretta
Car_________2__________ Chevy______Corsica
Car_________3__________ Chevy______Malibu
Car_________1__________ Ford_______Mustang
Car_________2__________ Ford_______Probe
Car_________1__________ Hyundai____Azera
Car_________2__________ Hyundai____Elantra
Car_________3__________ Hyundai____Sonata
Car_________4__________ Hyundai____XG
Truck_______1__________ Nissan______Titan
Truck_______1__________ Toyota______Tundra


Hope this makes sense. I'm pretty much a dummy when it comes to VB coding so I would greatly appreciate any help you can give me. Thanks so much!!!
Feb 23 '07 #1
5 2976
ADezii
8,834 Expert 8TB
Does anybody know a VB code that would populate the "AutoNumber" field each time it is run for my "Transpo" table in the manner depicted below?

I need the AutoNumber field to reset at the begining of each new group under the "Maker" field. It should be in ascending order by Type.Transpo, Maker.Transpo, Model.Transpo
  • Table: Transpo
  • Field1: Type
  • Field2: AutoNumber
  • Field3: Maker
  • Field4: Model

Type___AutoNumber______Maker______Model
Car_________1__________ Chevy______Beretta
Car_________2__________ Chevy______Corsica
Car_________3__________ Chevy______Malibu
Car_________1__________ Ford_______Mustang
Car_________2__________ Ford_______Probe
Car_________1__________ Hyundai____Azera
Car_________2__________ Hyundai____Elantra
Car_________3__________ Hyundai____Sonata
Car_________4__________ Hyundai____XG
Truck_______1__________ Nissan______Titan
Truck_______1__________ Toyota______Tundra


Hope this makes sense. I'm pretty much a dummy when it comes to VB coding so I would greatly appreciate any help you can give me. Thanks so much!!!
You cannot have a pure AutoNumber Field in Access act in this fashion.
Feb 23 '07 #2
Seems to me like you would use multiple tables, relationships, and foreign keys to do what you want to do.
Feb 23 '07 #3
KPR1977
23
Seems to me like you would use multiple tables, relationships, and foreign keys to do what you want to do.
Yes, but I'm trying to avoid that by using a VB code.
Feb 23 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
Yes, but I'm trying to avoid that by using a VB code.
The autonumber field can't be reset.

If you have duplicate values this field can't be used as a primary key.

It is not a good idea to try to bypass in any way the correct table structure design for a database.

Mary
Feb 24 '07 #5
NeoPa
32,556 Expert Mod 16PB
Does anybody know a VB code that would populate the "AutoNumber" field each time it is run for my "Transpo" table in the manner depicted below?

I need the AutoNumber field to reset at the begining of each new group under the "Maker" field. It should be in ascending order by Type.Transpo, Maker.Transpo, Model.Transpo
  • Table: Transpo
  • Field1: Type
  • Field2: AutoNumber
  • Field3: Maker
  • Field4: Model

Type___AutoNumber______Maker______Model
Car_________1__________ Chevy______Beretta
Car_________2__________ Chevy______Corsica
Car_________3__________ Chevy______Malibu
Car_________1__________ Ford_______Mustang
Car_________2__________ Ford_______Probe
Car_________1__________ Hyundai____Azera
Car_________2__________ Hyundai____Elantra
Car_________3__________ Hyundai____Sonata
Car_________4__________ Hyundai____XG
Truck_______1__________ Nissan______Titan
Truck_______1__________ Toyota______Tundra


Hope this makes sense. I'm pretty much a dummy when it comes to VB coding so I would greatly appreciate any help you can give me. Thanks so much!!!
It seems like you're confusing the Autonumber field type with a simple numeric field which happens to be populated automatically.
The Access Autonumber field doesn't behave wrongly. It actually works perfectly as designed. It was designed that way because the designers knew what they were about.
Your field won't be done automatically by Access (as I'm sure you've realised by now) but you can put in some VBA code to handle this in a form if you like.
Feb 26 '07 #6

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

Similar topics

2
by: Shaun | last post by:
Ok here is the situation… Have an access 20002 application that I'm converting to have a SQL Server backend (2000), the application has been in use with an access backend for years, no real...
7
by: manning_news | last post by:
I've got a report that's not sorting correctly. I build a SQL statement and assign it to the recordsource in the Open event, sorting the data the way the user chooses. The user can choose up to 3...
2
by: Michael Bialowas | last post by:
Hello all, I have been searching the net endlessly and found this ng, so I thought I would give a try. Anyways, I have a few problems I am trying to implement a combo box which presently contains...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
1
by: KRSharp | last post by:
I am new to Access, so bear with me. I think this is possible, but I am not sure how to get this going. I am trying to develop a database that will allow me to create a manufacturing schedule...
1
by: minkokiss | last post by:
OK so the situation is the following. I added my access database to my ASP.net project (I am using VB.net) and the links work perfectly and I can pull up the data in the datagrid view and...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Thank you for that. It was very...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: FRENCH GUY | last post by:
Hi everyone, At the moment, I am working on a database with several tables. Almost every table has her own autonumbering field. So herefore, I am looking for the command that I have to include in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.