Changing Primary Key To AUTONUMBER On Existing Database ?

Mar 30, 2007

I have an existing contact information database which consists of a number of tables, the main table has a primary key which is currently set to NUMBER.

There is a relationship between it and 2 other tables via that key (ContactID).

I would now like to change the primary key (ContactID) to AUTONUMBER, so that any new records added, have a number assigned automatically. I also need any newly created primary key number to be used in the child tables created as a result.

Is this possible ? (without renumbering my existing tables/records)

many thanks

View Replies


ADVERTISEMENT

Adding AutoNumber As Primary ID To Existing Table

Jan 31, 2012

I have a simple database that I inherited, that contains basic customer contact info. We want to start adding more functionality to the database, so I've done alot of research to learn about how to begin normalizing my data.The existing table does not contain a useful primary key, since we may have multiple individuals from the same company, companies with very similar names, etc.

I would like to add an AutoNumbered field to use as a CustomerID/primary key, but I can't seem to find a way to do so. Here is what I've tried so far:

I have tried to add a field to the table, and make it an AutoNumber data type. When I do so, I can error message saying that I cannot make a field AutoNumber if any other field in the table already has data entered in it.I have tried to create a new table containing only an AutoNumber PrimaryID field, and then import data from the existing table, but that just creates a 3rd table.

View 1 Replies View Related

General :: Changing Existing Database From Overall To Monthly Records

Nov 8, 2013

I'm altering a database to have certain fields be recorded monthly.For example: instead of a client's file having "Total X Purchased" it would now be "Total X Purchased - Jan", "Total X Purchaed - Feb".

I want to spin the monthlies out of the master clients table & in to ex. tbl_clientsJan, tbl_clientsFeb, etc. but still have them linked; & have a "Totals" table that aggregates data from all of the tables (adds them up).

I have an existing form, & I was thinking of just creating tabs for the months & subforms in each with their sources as the month tables, & removing the fields that don't change month-to-month (e.g. client name), with relationships between them. I would start by copying all of the master table data in to the month tables & allowing edits from there.

the company doesn't track when the transactions occurred; I'm unable to group them along those lines.I'm new to Access & don't want to make a mistake.

View 9 Replies View Related

AutoNumber Primary Key In Database Starts Jumping Suddenly By Thousand Places

Jul 14, 2014

The above image is of a table which I need to update according to a new data on daily basis. As you can see when I added two records at the last , the AutoNumber primary key of the table jumped by thousands . I have used the following query to update the table

Code:
db.Execute "INSERT INTO D_Counterparty (CPTY_ENTITY_ID,CPTY_DESC)"_ & "SELECT Ctpy_Entity_Id,Ctpy_Entity_Legal_Nm"_ & "FROM NewCU LEFT JOIN D_Counterparty ON D_Counterparty.CPTY_ENTITY_ID=NewCU.Ctpy_Entity_Id"

I never changed the AutoNumber from incremental to random and I have also tried re-seeding it but had no success. Also when I inserted the sample values using a sample table ,the AutoNumber was working fine . Here's that query

Code:
db.Execute "INSERT INTO D_Counterparty (CPTY_ENTITY_ID,CPTY_DESC,) SELECT a,b, FROM sample"

I did not use join in this query ...

View 2 Replies View Related

Add Primary Key Field To Existing Large Table

Apr 28, 2008

I have a table with more than 700,000 records. There are no unique fields or unique combination of fields. I would like to add an AutoNumber field but when I try I get the message:

File sharing lock count exceeded. Increase MaxLocksPerFile registry entry.

If I answer yes I get an error that the new field was not added. Is there any way to add a key foield to an existing database?

View 3 Replies View Related

Re-set Primary Key Autonumber

Aug 17, 2005

My shiny new database is ready to go - now I have deleted all my trial data and want to re-set the autonumber primary key of my main table to start at "1" (I thought I could delete it and re-insert it but it won't let me). Suggestions?

View 1 Replies View Related

Tables :: Autonumber Order In Existing Table

Jul 9, 2015

I was adding an autonumber field to an existing table and I assumed the numbering would follow the order of the primary key but that doesn't seem to be the case.

View 9 Replies View Related

Primary Key...Autonumber Or Custom?

Jul 10, 2005

Just a general question...
When you make a primary key is it better to use and Autonumber or a Custom one? I have for the most part used auto...easy, convienient and well I have never had a problem yet (been pretty serious on Access for about 1 year). But I just read that ref integ doesn't work on Autonumbers? which would also mean cascading update & deleting correct?
I have looked at Northwind Access sample and all except "Customer" they use Auto. Well then to make a custom Primary field wouldn't I have to do that at the form level? like "CustomPrimKey = Left([CustFirstName],2 & Left([CustLastName],2) & [PriKeySetAtAutoNum]" or something like that to get what I want. I imagine you would automate this as opposed to letting the operator manually enter them.
And then as in the Northwind sample how do you know which tables need the custom numbering and which ones don't.
As I have learned on my own some of the "basics" elude me until they come back to bite me.

Thanks

View 10 Replies View Related

Creating A Primary Key With Autonumber

May 4, 2007

Any ideas on tagging my primary key (currently autonum as a data type) with an "M" on the front of it. I guess i wanted to keep it as autonumber so i wouldn't have to key in a value

Thought maybe i could create a new field and do an "M" & [ID] in the default value where [ID] is the autonum primary key field but I guess I'm not doing it right - get an error trying to save saying it can't find the field [ID]


thanks for any suggestions!

View 5 Replies View Related

Primary Key Autonumber With Letters

Jun 25, 2007

Hi!
I am a new member of this forum and new to access.
I need to make a data base and I would to have my primary Key as an autonumber. I would like to use ID numbers that have already been assigned but they have letters in the beginning, they are GKAD0001 etc. so at the moment I just have them as text that wont allow duplicates, but really I would like them as and autonumber so when new data is added it automatically assigns the next number.
Is this possible?

Thankyou very much for your help.

View 2 Replies View Related

Autonumber-primary Key Across 2 Tables

Feb 1, 2008

Hi,

I need to create a table with 2 sets of different information both referring to job types. the problem is that i need the autonumber which created the job number to scale together. so both tables have a primary key of "job number" and i want the autonumber to only ever use 1 number in both tables.

e.g.


job type 1 - autonumbers - 1,2,3,4,6,7,9,10
job type 2 - autonumbers - 5,8,11,12

is there anyway of achieving this?

Any help greatly appreciated

View 5 Replies View Related

Hide Autonumber Primary Key ID

Apr 15, 2005

I am new to Access, and have spent the last few weeks reading everything I could get my hands on about creating databases. I am working on a new database for my office and I need some help please.

I am trying to create normalized tables, so I have broken down my tables into the smallest possible field groups and linked the tables via primary and foreign keys using autonumbers and the primary key in parent tables. My question is how do I have my users interface in forms with actual data instead of the ID numbers but have the ID numbers inserted in the field. Here is a sample of my address table to demonstrate my question:

tblAddresses
AddressID Autonumber PK
StaffID Number (FK to tblStaff)
AddressTypeID Number (FK to tblAddressType)
Address1
Address2
CityID Number (FK to tblCities)
StateID Number (FK to tblStates)
ZipID Number (FK to tblZips)

Obviously all of my tables are not shown here but this should show what I am looking for.

So, how can I let the user input/select the actual data from the forms in combo and text boxes but actually input the ID numbers into the underlying tables. If a user is inserting a new record and selects state I want them to be able to input/select CA not the StateID 1.

I don't know why I am having such a hard time with this, I seem to understand the other concepts but this one has me stumped. I found a few ways to do it, but I don't think they are right and I want to learn this the correct way. Any help is greatly appreciated, thanks!

View 6 Replies View Related

Linking Tables Using AutoNumber Primary Key

Mar 13, 2006

I have three tables.

EAch has a field called ID that is an Autonumber that is the primary key.

When I enter data via a form each record has a different ID across the three tables.

Does this mean they are not linking up correctly?

I have attached my databaset if that helps.

Thanks.

View 1 Replies View Related

Copying Primary Key Autonumber To Another Field

May 9, 2007

Hi,

The database I've inherited has a primary key autonumber set up which is randomly generating numbers. It also has another field which has yet to be used, of a clients reference number.

I thought it would make sense to use the reference number field as the primary key, as it seems redundant otherwise and it would give us another field to perform searches on (if we record a clients reference number on their paper file, then finding them on the database would be much quicker).

Because of the relationships in the database, I didn't want to remove the existing primary key as I'm afraid it would mess up the whole thing. I was wondering if there is a way of having the autonumber which is generated in the primary key to be automatically copied to the clients reference number field? This would leave the primary key intact but give us this extra level of information to search on.

Thanks.

View 1 Replies View Related

Set ID Primary Key (autonumber) Field Back To ZERO

Sep 30, 2005

Hi there,

strange query... I have a testing database which I have filled full of test data. I now want to create an empty copy of this database, so I copied this, removed all records, however the tables where I have a field named ID, which is the Primary Key field and is Autonumber set to increment, I cant seem to get this to set back to 1. I tried deleting the ID field completely, closing DB, and adding it again, yet it STILL remembers the next number up from the last record I had created previously??

Can anyone offer any help as to how I can get this set back to 1, as now I am finished testing I want to essentially start all table records fresh.

Many thanks for your help as always,

View 5 Replies View Related

Table With Primary Key - Autonumber In Increments

Jun 25, 2014

I have a table that has a primary key that does an autonumber in increments. Then I made some queries that will append records by date and then also another query that will delete what was appended. Then I created a reverse sequence of this process in case I change my mind and would like to put back the records I archived, however, when I do this, the primary key is now thrown off and will still revert to the last primary key that was appended before the archive ever took place. In other words it still thinks that the records I appended before I did the reverse, are still there. So now it will not let me save the record because it is a duplicate.

Is there a way to set the autonumber for the primary key to where I want it to begin?

View 14 Replies View Related

Using AutoNumber Primary Key On Sorted Column

Mar 4, 2013

I've just begun using microsoft access and would like to create a primary key on a table of data that has been sorted alphabetically. However, when I try to create this key (designview -> auto number-> increment) it autonumbers for the column the way it was before i sorted it. Is there a known way of doing this?

View 7 Replies View Related

Modules & VBA :: Insert ID (Autonumber) As Primary Key Field

Jun 5, 2015

How can I insert an 'ID' field into an existing table at first field as primary key using AutoNumber? The table will then be populated.

View 9 Replies View Related

Changing Primary Keys

May 1, 2005

Hello all,

I am re-working an old database that 'grew up' the wrong way. It is a medical patient database and has 4 main tables. Primary key of main data table is Medical Record number (MR#), a user entered field (I know...). This links to 3 other tables: Diagnoses (indexed by MR# as well, 1-to-1 relationship with main table), Consults (indexed by a compound key of MR# and date, 1 to many relationship), and Procedures (indexed as well by MR# and date; 1 to many as well).

Here is my plan, and I want to know if I'm going to go about it the right way:

I will first delete the relationships between these tables.
I will then give the main table an autonumber field called PatientIndex, and each other table their own autonumber (DiagnosisIndex, ConsultIndex, ProcedureIndex). I will also give each of the other 'daughter' tables a PatientIndex field as well. I will populate the PatientIndex fields of the daughter records with a VBA routine that matches their MR# with the MR# in the main table, and then inserts the corresponding PatientIndex.

Now that each table has no relationships, and has all the right fields, I suspect Access will allow me to change the Keys for each table, and create new relationships, and it should all work cleanly. The goal is to have each table indexed by an autonumber field that is unrelated to user entry, and to link them by the Primary key.

Does this sound like the right approach? As to why do this if it works OK, it's a matter of maintenance. It's simply too buggy as it stands, and it's torturing me. Will my plan work without crashing the db?

View 5 Replies View Related

Changing The Primary Key Of A Table

Aug 4, 2005

HI

I did some BAD planning before I started creating my database and I set a text field ("field1") of a table ("table1") as primary key, then I linked this field to a field in another table ("table2", one-to-many relationship). Now I wan't to change some values in table1 in "field1" defined as primary, but I can't (Access refuses to do so...).

Because I have a lot of data entered allready I would like to know if there is any way for me to change values in "table1"/"field1" and that all the linked fields in other tables ("table2") would change correspondingly??????

I hope my question is clear enough to understand.

thanx in advance

View 5 Replies View Related

Changing The Primary Key Error Message

Mar 12, 2006

hello

is it possible to change the default primary key error message that appears when a duplication of the primary key is made in a form?? in other words how can i make those error messages more user friendly??

thank you :)

View 5 Replies View Related

Queries :: Changing Primary View

Jun 12, 2013

I was wondering if it is possible to change the primary view for queries from the table view to say, the Pivot Chart view?

View 7 Replies View Related

Changing The Starting Number Of The Autonumber

Apr 7, 2007

I have a table with a compound key, and one of the two fields in the compound key has to start at 100 and finish at 999 and I'd like it so that each number didn't have to be typed in individually.

So I thought about using an autonumber that somehow starts at 100 but doesn't go over 999 if thats possible? Or if you have any other ideas on how I could achieve this?
Thanks

View 1 Replies View Related

Changing The Starting Number Of An Autonumber?

Apr 7, 2007

I have a table with a compound key, and one of the two fields in the compound key has to start at 100 and finish at 999 and I'd like it so that each number didn't have to be typed in individually.

So I thought about using an autonumber that somehow starts at 100 but doesn't go over 999 if thats possible? Or if you have any other ideas on how I could achieve this?
Thanks

View 1 Replies View Related

Changing Misspelled Record In Primary Key Of Table

Sep 27, 2011

I want to change misspelled records, but the misspells are in the primary key of my table. By changing the values of primary key fields, can I break table relationships? I'm not changing field names, just field values of a primary key field.

View 5 Replies View Related

Updating And Existing Database

Jan 17, 2007

Hello


I have a database which i am constantly updating and improving. I have a few friends who use the database in a current form. If i made an update say to a form or to some of the coding to make the DB more efficent, how can i update the dBs my friends are using without damaging or changing the existing data, or migrating it to the new design.

I.e going from version 1 to version 1.1

Any advise would be great?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved