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 Replies
ADVERTISEMENT
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
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
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
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
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
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
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
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
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
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
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 6 Replies
View Related
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
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
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
May 1, 2014
i have 4 supplier tables with identical field names but different databases in sql.I want to have them all in one table and only want the information for reference i do not want to edit any of the data.I need to create a new primary key number for the complete table. The data will need to be refreshed as the data comes from MMS Sage looking at company PLsuppliers.
I have tried a linked SQL union view- but this has no primary key.I need to keep the Primary key consistent as the data saved in other tables will use this field.The overall goal is creating a Purchase order system and this list will be my complete supplier list.
View 2 Replies
View Related
Aug 20, 2013
I have mapped everything out and built it in Access (but haven't entered any data yet). My question relates to structure. The data is based on artifacts, each piece is recorded with an automatically generated primary key in the main table. There are a number of features (type, decoration etc.) that are documented in related tables (included in/linked to the main table with foreign keys). Aside from these (the features I will query on), each piece has a number of characteristics to be recorded (size, colour etc.). Because of form/table size, I have broken the information into three tables (a main table with ID details, a second with Sizing and Dimensions, and a third with Materials etc.).
My question is: Can the main ID primary key from the main ID table also be used as the primary key in the 2 other basic information tables, with these 2 linked to the main table in one-to-one relationships (so it's an auto-number in the main table and an integer in the other two). This to me would be much easier to navigate than to have one long giant table with all these basic details.
I have created a main data entry form with a "navigation form". 5 tabs/pages. Tab/Page 1 = main ID. 2 and 3 are the two broken apart tables mentioned above. 4 and 5 are forms based on related tables that have their own subforms included. Both 4 and 5 are based on tables in which the main ID primary key is entered as a foreign key (in one-to-many relationships with the main table). Since this was done with a navigation form (instead of adding each of the 4 as subforms), will it still allow me to enter all relevant details for one piece into each tab/page, and save it all together automatically (whenever I enter a new piece into the main ID form)? Will the primary key be automatically generated throughout, or do I have to enter it manually in each tab/page?
View 7 Replies
View Related
Mar 13, 2014
My Access 2010 skill level is intermediate.I have a table with 4 fields.
EmployeeID (Primary Key)
LastName
FirstName
SupervisorID
The problem I have is that in the Supervisor field, it identifies the supervisor by his/her EmployeeID. I would like to create a query or merge tables so that the SupervisorID can look for a matching value in the EmployeeID field and return the last name/first name.
View 5 Replies
View Related
Aug 28, 2013
I am importing data from excel and I want to put a primary key on a column but it doesnt let me saying "primary key cant contain a Null value", coz I have a "NO" or "O" value. But i dont understand why is it a problem as I have specified the field as text not number.Also is it necessary for the table to have a key ?
View 14 Replies
View Related
Jun 2, 2013
Composite Primary Key in Ms Access 2010. I shall try and explain my tables in detail. So my first table is "Client Database" where the field "Buyer" is primary key. This is connected to my next table "Project Database" which has fields such as Work Order #, PO #, PO Date , Buyer etc where Work Order # is the primary key. Finally "Projects Database" is connected to Order information. Now the problem is until now, I always had 1 PO # for each Work Order #. However now I am facing a situation where my client has clubbed multiple PO #'s for the same Work Order #. I need to trigger the Primary Key Violation only if both the Work Order # and the PO # are the same.
View 8 Replies
View Related
Oct 12, 2007
I have a MAIN table with autonumbering for the project number. In a table related to the MAIN table I have a project number that I want to be updated when the MAIN table has a new project entered. Can I keep these in sinc automatically?
View 8 Replies
View Related
Aug 1, 2005
I have constructed a DB for work to record accidents, however I am running into problems. On each form I have a button that Saves the data closes the current form and opens the next form, depending on what data was entered. I have this ruuning fine using this code,
Private Sub SaveRecord_Click()
Dim NextForm As String
If Me.Status = "Pupil / Child" Then
NextForm = "StudentDetail"
Else
NextForm = "EmployerDetails"
End If
DoCmd.save
DoCmd.Close
DoCmd.OpenForm NextForm
End Sub
Private Sub SaveRecord_DblClick(Cancel As Integer)
Dim NextForm As String
If Me.Status = "Pupil / Child" Then
NextForm = "StudentDetail"
Else
NextForm = "EmployerDetails"
End If
DoCmd.save
DoCmd.Close
DoCmd.OpenForm NextForm
End Sub
The primary key of this form is "PersonKey" and the two forms taht could open, each have"PErsonKey" as a foriegn key. However the key does not get brought across into the next form and the save function does not appear to work on all forms... :confused:
I put another button on this form using the control button wizard, and it gave me this code,
Private Sub Command23_Click()
On Error GoTo Err_Command23_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_Command23_Click:
Exit Sub
Err_Command23_Click:
MsgBox Err.Description
Resume Exit_Command23_Click
End Sub
However when I run this from the form, it tells me that the "PersonKey" field needs a value.... :confused:
View 6 Replies
View Related
Jun 15, 2006
Hi guys,
I am having problem with a query.
I have to tables. One named wire and the other named Input.
As my title says there is not unique ID for the tables to relate.. the only thing to relate is one ID where is not unique for all the rows
In the Wire Table I have 3 rows using the same ID, lets say 123.
In the Input Table I have 1 row using the same ID as above, i.e. 123
I need to select a couple of fields from Wire Table and 1 field from Input Table
The only relationship I have is the ID 123.... since the ID in Wire Table is repeated in 3 rows.... I would like to use the same value from the Input Table to be the same for the 3 rows in the other table.. Below is an example:
Wire Table:
ID Group
123 A
123 B
123 C
Input Table
ID Description
123 Analog
My wanted result would be
Group Description
A Analog
B Analog
C Analog
I tried using the Left join or Join function, but somehow the resulting table has many duplicates of the rows...such as:
Group Description
A Analog
A Analog
A Analog
A Analog
A Analog
B Analog
B Analog
B Analog
B Analog
...
Any Idea on whats going on and how can i solve this problem????
Thanks in advance. Your Help is much appreciated
View 1 Replies
View Related
Sep 16, 2013
In a many-to-many relation, one create joint table and use two columns of both ID's in a Composite way. This what the text books recommend.I had a Form/subform to view the relation between the two table. I tried to add to the subform a new relation Access did not allow me to do it. I can go to the joint table in datasheet view and ADD to my heart content observing the unique condition.
If I change the design of the joint table to auto as PK and the two ID's with no PK in either, I can update from the subform .WHY the Composite Keys do not allow me to update the joint table by adding new records in the subform ???
View 6 Replies
View Related
Jun 25, 2013
I have just inherited a database that currently has no primary key set up. I wanted to add a two part primary key, but have run into a couple problems. The purpose of the database is to keep track of parts that have come back for repair. I wanted to set the key up to be a combination of the call number and the part serial number. I should always have a serial number, but the serial number can be in the table more than once, as it could have needed repaired more than once. I will normally have a call number for each record.
However, the call number could be repeated more than once, if more than one part came in on the call. The combination between call number and serial number should always be unique (each time a part comes in, it should be on a different call). My problem is arising, when a part is just pulled off the shelf of the factory and sent in for an upgrade. In a case like that, there is no call number. However, a serial number will never come in more than once without a call number.
So the combination of call number and serial number should still remain unique. When I try to set this up in the database, it tells me that the primary key cannot contain a null value (referring to the times that a serial number comes in without a call number). I want to get this set up so that the people entering data in the database will not be able to enter the call number, serial number combination more than once. How can I do this if one part of the primary key can be null?
View 5 Replies
View Related
Sep 24, 2012
I have two tables tblPatients (pkUMRN) and tblAdmissions (pkAdmissionID, fkUMRNAdmission). pkUMRN is not auto-number, but is an 8-digit alphanumeric code unique to each tblPatients record. I have set up a one-to-many relationship between tblPatients_pkUMRN and tblAdmissions_fkUMRNAdmissions (each patient can have multiple admissions).
Is it possible to allow the entry of a new tblAdmissions_fkUMRNAdmissions to create a new tblPatients_pkUMRN? IE can you create a new primary key from a new foreign key?
Along a similar line, if the primary key already exists, how would you autofill a form with data from tblPatients when the tblAdmissions_fkUMRNAdmissions is entered in to the table?
View 6 Replies
View Related