Change Primary Key And Update Data?
Jul 25, 2007
Hello,
Firstly, I am very much self-taught on access, so there are several gaping holes in my knowledge, and my database structure is probably not wonderful! I have been learning as I go along, so in the initial stages I have built in several problems which I am now discovering!
My db is designed to track suggestions - i have a table where the idea, progress etc is stored [tblIdeasBank]. This contains an 'originator' (person's name) which is linked to a second table, where the names are stored [tblPeople].
Originally I set up tblPeople with the Primary Key as FullName (e.g. Joe Bloggs) (guaranteed to be unique with the small number of people that would be involved), and a second field called InitialLastName (e.g. J Bloggs). It is this second field that is stored in the tblIdeasBank. Data verification came from the user having to select a name from a drop down box, so there is no actual 'relationship' between the tables. (Didn't realise how useful they were at the time!)
The db has been so successful :confused: that it is now going to be rolled out across the company, which gives me two problems. To populate all the names, I need to import them from Excel, where I will have FirstName and LastName. I have now realised that it would be more sensible to just store these, and create InitialLastName where needed. Also, I may well have duplicate names, so I need to create a unique ID, and a proper relationship. (Yes, I know I should have done that in the first place).
So, I have:
tblPeople:
.FullName (Primary Key)
.InitialLastName
tblIdeasBank:
.Originator (stored as InitialLastName)
And I would like:
tblPeople:
.PersonID (Primary Key)
.FirstName
.LastName
tblIdeasBank:
.IdeaID (Primary Key)
.Originator (stored as PersonID)
With a One-Many relationship from PersonID to Originator
Any ideas how I would go about doing this and changing the Originator for each idea from InitialLastName to the relevant PersonID number, without corrupting the data?
I have searched through Google and various groups, but cannot find a useful answer, so any pointers gratefully appreciated!
Thanks,
Nick
View Replies
ADVERTISEMENT
Oct 18, 2011
I am new to access 2010. I need to change the primary key in a table ("stations", Primary key is "station number"), because future entries will result in double entries for this primary key.
I have another table ("species&stations") which has records of Species for each "station number".
So I created a new Primary key for the "stations" table, now called "species id", being a bit better in defining a unique station (as it contains the year and the species number, i.e. "451_2010")
Now the table "species&stations" references/(is in relationship with) the old primary key, identifying a station number for each record.
How do I get it to recognise the new primary key from the "stations" table, and keeping the records (over 1000...) with all there info.
Approach so far: I tried to create a new field in "species&stations", which should look up the new primary key from "stations" and then autofill the field. i did not manage this though
I attached a screenshot to make the relationships more clear!
View 2 Replies
View Related
Feb 17, 2008
i'm a Access novice. I have tables with existing data in numerical form, and would like to know how I can use Queries or VBA code to update these values into a new format in a new table. for example the original data might be of race type:
1 - caucasian
2 - african american
3 - hispanic 1
4 - hispanic 2
5 - hispanic 3
6 - other
and i want to regroup these into less types, eg:
1 - caucasian
2 - african american
3 - hispanic
4 - other
how can i achieve this in Access? i know how i can do this conceptually with "if" and "case" statements, but I have no idea how i can do this in Access. I don't want to mess with the original data, so please help with CODE or QUERY examples.
thanks!!
View 4 Replies
View Related
Mar 13, 2014
I have our primary web based inventory system that I am exporting to Excel and using this as an import to Access for the main raw data for my database. This being inventory it changes daily so I am updating this table every day. When I try to append the table it ads all the records. I am wanting an easy way to add only the new records/take out the ones that are no longer there. Basically update the table with what is currently there.The only have I have found to do this is by running non-matching queries and update queries.
View 2 Replies
View Related
May 31, 2006
How would I go about changing the primary key to a different field in a table? :o Thanks for any help!
View 2 Replies
View Related
Jun 28, 2007
How do I reassign a new PK for may tables.. they're already related and there about 2,000 records on the Main Table and like 6000 records on the related table.... I used a wrong PK and I want to create a new (long Integer Auto-Number) but I don't want to lose what I've done already.
View 7 Replies
View Related
Nov 19, 2011
Can I change the primary key currently set to my products description to an auto number? I'm trying to make things right, also does the foreign key get an auto number?
View 2 Replies
View Related
Jun 3, 2013
I created a database that I want to move to a server for others to access. When they open it, it says invalid path. It's looking for my desktop. How do I get this whole database moved to a shared location on a server?
View 8 Replies
View Related
Sep 28, 2015
Currently we have a web based order taking/inventory system. Every night they export a .db to an FTP server and every morning I download it (I automated this part, it replaces the older file). I link to this database (using SQLlite3 to ODBC driver) from an Access database for specifically this purpose.
When I originally created it I had to go through every table and create a unique identifier. Unfortunately I chose poorly in some cases. I can't figure out how to get those primary keys changed to the correct ones. I've tried recreating the ODBC connection, tried a new database and new ODBC connection, tried killing the connection waiting a day (for the new .db to download) and recreating the connection and trying it in a new database.I know access doesn't allow you the change the primary key in a linked table.
View 14 Replies
View Related
Apr 21, 2006
Hey, I am getting a primary key violation when I try to run an update query.
My primary key is a combination of two fields, ScheduleID and SchedulePage. That way for each schedule I can only have one Page 1, one Page 2, etc.
When I want to insert a page (say a new Page 2), I need to update the table so that Page 2 becomes Page 3, Page 3 becomes Page 4, and so on.
The problem is, since it starts at the bottom, when I tell it to increase the page number by one, it's conflicting with the primary key of the next record.
Any ideas? BTW, if the solution has to do with sorting, I need to make sure it's something that always defaults back to the correct sort, since users may be able to change the sort and accidentally save it. Plus, I'll need to do the same thing in reverse (delete a page).
DoCmd.RunSQL "UPDATE Pages " & _
"SET Pages.SchedulePage = [SchedulePage]+1 " & _
"WHERE (((Pages.ScheduleID)= " & varScheduleID & ") AND ((Pages.SchedulePage)>" & varSchedulePage & "));"
View 3 Replies
View Related
Mar 8, 2007
My database tracks all of the staff development sessions provided for the past ten years, thus we have thousands of records. Our school district wants all departments to move away from using an employee's Social Security number to a number assigned by the district. Each employee has been assigned a unique six digit number.
In my staff development database, the employees data (Social Security number, campus, job description, etc.) are in a table, "EmployeesTbl", with the primary key being the Social Security Number. Classes data are in a table, "ClassesTbl" with some of the fields being ClassNum (an autonumber), class name, class description, etc., with the ClassNum being the primary key
in this table.
A third table, "AttendTbl", links the two and shows each class (staff development session) each employee has taken. This table has a a foreign key, "SocNum", that links it to the EmployeesTbl, and another foreign key, "ClassNum", that links it to the ClassesTbl.
I have added the EmpNum field to the EmployeesTbl, and all of the the district assigned employees' numbers have been entered. I have also added this field to the AttendTbl. Is there a means of using a query to fill in the employees number in this table. Is so, I'll then change the primary key in the EmployeesTbl to be the employee number and the foreign key in the AttendTbl to be the same. If not, we face the task of having to key in 18,000 records!
Thanks for any help,
R. Sanders
View 14 Replies
View Related
Dec 16, 2013
I want my primary key to be
First 3 letters of surname + first 3 letters of forename + DD + YY (Date of birth)
I can use the after update event to update the primary key field but it won't get saved for some reason so have I missed something?
View 13 Replies
View Related
Apr 5, 2014
I am trying to change the button color on a subform if a related form data changes.Main form is products with a continuous subform with serial numbers of products i.e, serial number, location, price and a button to add addtional issues if there are any for this particular serial number (this will open up another form related to the serial number so I can add an issues if there are any).The reason I would like the button to be a different color is so I can quickly see if there are any additional notes been added to the serial number. Just in case you may ask why not add the field to the continuos form is that the issues and be quite lengthy and there may be lots of serial numbers on the form
2346 location warehouse price 29.99 (button - green)
2347 location shop price 29.99 (button - red)
View 1 Replies
View Related
May 22, 2014
My problem is that I am trying to update a field (called 'Sold' which is a yes/no checkbox column) for a specific record whenever an event is triggered. I have two forms (derived from two tables), one is called frmInventory and the other is called frmSales. In frmSales, I made a combo box called 'cboItemID' that allows the user to select from a list of items from my inventory table. Each selection from the list has 4 properties, the first of which is the 'Item ID' from the inventory table. Lastly, I have a field in both frmSales and frmInventory called 'Sold' as mentioned above. What I want to do is that whenever I check/uncheck the box in the 'Sold' field in frmSales, I want the 'Sold' field in frmInventory to check/uncheck as well, but only in the record with an 'Item ID' that matches the 'Item ID' from the combo box selection. In other words, I want to match the 'Sold' field in frmInventory with the 'Sold' field in frmSales, but for only the record that has the same 'Item ID' primary key as the one I picked from my selection in the combo box from frmSales.
how to reference another table and check whether or not it's 'Item ID' primary key is identical to the one I specified from the combo box, and then take action to update the 'Sold' field if the IDs match.
View 1 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
Sep 18, 2006
Before you start yelling, use the search. I did.;)
But the solution mentioned on this forum (place me.lastupdated = Date() after BeforeUpdate event) doesnt work for me. My situation: I have two forms. On the first you are asked for an registrationnumber. This is used to open the second form with that registration number so you can fill in data. I want the date on which things are changed on the second form to be saved. If I use the BeforeUpdate event, I get an error when I try to open the second form. When I use the AfterUpdate event, the date is changed but not stored. Any solutions? :confused:
View 3 Replies
View Related
Dec 12, 2012
I'm using Microsoft Access 2007
I have three tables: the 1st is for product's identification, the 2nd is for registered products, and the 3rd is for under-registration products
and the primary key for the three tables is the Registration Number
and there is a one to one relationship between the product identification and the registered products
and a one to one relationship between the product identification and the under registration products
What I want to do is to make an append query to move the under registration product to the registered product when its process is over.
One of my problems is with the primary key for the under registration products table, as they only get their registration number when the process is over. so how can I enter data into this table without the value of the primary key ?
View 14 Replies
View Related
May 27, 2014
I have an access table which has a key using letters (A,B,C,D...etc). Against each letter there is multiple rows against each letter. However for testing purposes I only need to get a single row against each key and I was wondering if there is a function I could use which would return only the first record of data for each key?
View 4 Replies
View Related
Apr 19, 2007
G'day, I'm trying to replace a date on a table using an update query. I have the criteria set to [enter date] but it won't put it in the update to block. I know this has to be one of those easy one but after a search and using help I can't nail it down. Much appriciated, Tim
Guess I should add that I'm going to use a command button on a form to run the query and I want it to prompt me for the date.
View 6 Replies
View Related
Jul 26, 2006
So i have a field called [LastUpdate] that i want to have change to the current date to show when the form was last updated. which event do i use to make this happen and should this be a form event or this field event? I tried using the On Data Change even for the form and then just assigning [LastUpdate] = Date, but that didn't do anything. any ideas?
View 3 Replies
View Related
Sep 12, 2007
I have a list of codes that need to be changed if it is part of the a list that need to be updated after being entered into the database. I created a function that holds the old values and what they need to be updated to. To get this accomplished on a form do I just need to write a Update query and then reference the query to the appropriate field I am trying to update with new codes for the 11 codes needing to be changed and leaving the other codes the same.
View 1 Replies
View Related
Aug 11, 2006
Hi all, I currently have 2 databases: a main current database (Main.mdb), and a secondary database (Working.mdb).
They are identical, except the working database has no data, just the existing tables, forms, etc. from the main database.
When I (or a programmer) makes changes to the forms and some underlying calculations, they are first made in the Working database.
After the changes are made, i delete all the data from the tables in the working database (data from testing, etc.). I will then copy all of the data from the tables in the Main Database over to the Working database, then rename the Working Database to the Main Database.
The only problem I'm having right now is that the primary key in one of the tables (ClientID) is an autonumber. When I paste the data into the Working Database, all the ClientID numbers change. Is there any way to keep the numbers the same as the Main database?
Thanks in advance!
View 2 Replies
View Related
Mar 25, 2007
I have a database that I imported as a comma deliminated csv file. To keep my original text comas intact I changed all the commas to semicolons before I created the csv file and imported the data. I now have a data base with semicolons in place of the original commas.
I am trying to use the update query function to change all the semicolons back to commas in one of the database fields called File_name
I have a data entry where a record in the File_name field looks like this for example
Chevrolet cavalier; red
and I want to change it so that it looks like
Chevrolet cavalier, red
I run an update query with the criteria set as Like "*;*"
and this finds all the records which have a semicolon in them
I have set the update field to "*,*"
but all this does is to change the record from
Chevrolet cavalier; red
to
*,*
Is the query update the way to go and what is the syntax that I should be using in the Update field just to change the semicolon to a comma and leave the other text intact?
thanks Mark
View 1 Replies
View Related
Dec 16, 2013
I am trying to update values in an unbound text box based on a selection in the combo box on the same form; however whilst I am easily able to display the information for the first selection the values do not update when I change the value in the drop down.
View 7 Replies
View Related
Apr 17, 2015
I'm working on a report that highlights employees when they are leaving on travel and returning on travel and my problem is that the report is only run on the weekdays. It highlights all employees that returned yesterday so for instance on Monday's report it only shows people that returned Sunday and not Friday and Saturday.
My first thought was to make an update query convert those days to Sunday in a new column on my table which would then still cause the employee to be highlighted on monday. I made a table with all Fridays and Saturday's in the year and then in the second column is the Sunday Date to update the new field.
I haven't been able to get the update query to work correctly and was wondering if there would be a much easier solution so a person wouldn't continually extend the weekend table manually.
View 3 Replies
View Related
Feb 2, 2014
I have imported a list from Excel into my database. The primary key is long integer (Indexed no duplicates). After the (successful) import, the next primary key assigned to a new record has jumped from (for example) 15 to 30024455. Why would this be? I have compacted and repaired the database (Access 2007) in case it was some kind of corruption but with no effect. Any primary keys on tables where I have not imported data works as expected i.e. incremented by one.
View 7 Replies
View Related