Automatically Creating A Primary Key Without Autonum
Jun 2, 2005
I'm pretty new to access and I've been working on a pretty complex project...
Anyways, my first problem I'm having is that I want Microsoft Access to automatically create a key number. This number depends only on the year, and then it would concatonate another number.
Example: 5-3000, then 5-3001, 5-3002... The five corresponds to the year, and the other part is just incrementing by one for each new record.
What would be the best way to do this? I don't necessarily need the dash in there, it could simply read 53000, 53001, 53002, etc.
Thanks for the help!
View Replies
ADVERTISEMENT
Aug 15, 2005
Hi
I've compiled a make table query and would really be happy if I could automatically assign a primary key to one of the fields i.e account ref.
Any ideas, suggestions gratefully appreciated
Cheers
paul
View 1 Replies
View Related
Sep 2, 2015
can I create primary key with macros automatically.
I have created table with Query and I need primary key in this table. I put new field for primary key but after restarting it was delete every time.
View 14 Replies
View Related
May 23, 2005
Hi guys
I am trying despereatly to fulfill this function with a macro
any help will be appreciated
I know this may be easy but the help files isnt helpful- so what else is new ;)
Database- C:sports.mbd
table - tblbasketball
current primary key - ID
new primary key needed- ID, EMPNO
The following codes dont work :(
ALTER TABLE tblbasketball
DROP CONSTRAINT PK_tblbasketball PRIMARY KEY
View 1 Replies
View Related
Jul 9, 2015
I have an employee table(parent) and family (child)members table. I have a field in the Family table called employee which i have created the one(employee) to many (family relationship). When I add a new family member why does the employee id not show automatically show in family table. I have to add it manually.
View 6 Replies
View Related
Aug 8, 2015
I want make one database about office register. I gave primary key for auto increment serial number . That is working fine. Now problem is some times I want delete client name in between table .That is maybe first row or 5th row or anywhere . at the time the row deleted which is i was selected but the primary key is not update . for example I want delete 8th row . after deleting I not seen 8 in primary key place i have seen only ....,5,6,7,9,10...... etc. how to give auto increment and decrement in the primary key......
View 3 Replies
View Related
Aug 8, 2015
I am new in ms access , I want make one database about office register. That is Have done . I gave primary key for auto increment serial number . That is working fine. Now problem is some times I want delete client name in between table .That is maybe first row or 5th row or anywhere . at the time the row deleted which is i was selected but the primary key is not update . for example I want delete 8th row . after deleting I not seen 8 in primary key place i have seen only ....,5,6,7,9,10...... etc. So how to give auto increment and decrement in the primary key......
View 2 Replies
View Related
Nov 24, 2004
I think that creating a new primary key is the only solution to this problem, but I would love to have other input, including potential pitfalls I might encounter in this process.
Here is the scenario: I have spent the past year creating a "survey based" database in my "spare" time at work. The database holds detailed information about nutrition questionnaires given to children over the years that they are in our program. I have based the structure on using ClientID as the primary key. ClientID = each individual's social security number.
We have another database that holds all the client's information. This is the database where any updates are done to their information. I export the client information (firstname, lastname, birthdate, socialsecurity, plus a few more) that I need into excel. Then I import that info into my database on a regular basis using an update/append query.
We started using the database in September and all was going well until a few weeks ago when I imported data and found a name that was entered twice. On looking closer, I found that the person had two different ClientID's. How could this happen...? Well, in our other database, if a child doesn't have a social security number yet, or we weren't given it, the program creates a fake social security number AAA-##-####. I knew this from the beginning, but wasn't aware of any problem. However, I was missing a significant piece of information. When the child finally does receive a SS#, we go in and change the number in the program!!!! At first I was told this rarely happens (I had about 6 duplicates the first time), but today I ran another import and found 90 instances of duplicated names!
There are just over 600 records in the database. Many of these have had information that is unique to this database entered in a related table, so I need to be sure I don't lose any of that data. There is data in other tables that I could import again if I have to.
Here are my options as I see them:
1. Leave the primary key alone and delete the duplicated values with every update.
2. Create a new unique autonumber primary key, knowing I will have to delete relationships and rebuild them. I would leave the clientID field in the system as it is the only way we have to determine the difference between two children with the same names and birthdates.
3. Run quietly away hoping they don't notice the problem until I am long gone. ;)
What would you do in these circumstances? If you agree with my assessment that I really should create a new primary key, what steps would you take to minimize problems both during the process and in the future?
And yes, I wish about 12 months ago, I had asked if the social security number was ever updated, but of course no one thought to bring that up when we were discussing the database design! :mad:
Thanks for your help!
View 2 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
Nov 20, 2013
I want to create Customized Serial Primary Keys and dont know how to go about it.
View 7 Replies
View Related
Aug 9, 2005
Background to question:
Here are 4 Tables:
1) ITEMS
IID (PK, autonum)
2) COMPONENTS
CID (PK, number)
CName
3) Assemblies
AID (PK, number)
AName
4) XREF
CID
AID
ITEMS is the only place where the unique IDs are generated. (This is done to allow any new table (e.g. PDF_SPEC) to be joined to one source ITEMS). When a new component is defined, it is assigned an ITEMS!IID automatically and that is copied to COMPONENTS!CID. Similarily for ASSEMBLIES. This way there is no component that has the same ID as an assembly.
XREF allows building the assemblies out of components.
Relationships:
ITEMS is one-to-one with COMPONENTS and it is also one-to-one with ASSEMBLIES, while XREF is infinite-to-one with each of them.
Question 1: How do I do the query such that when I add a component (or assembly) the new IID is generated and copied to COMPONENTS (or ASSEMBLIES)? I tried this and get the message: "Index or primary key cannot contain a Null value".
help!
View 8 Replies
View Related
Jul 31, 2005
I am using autonum to generate record numbers sequentially - three questions:
1. How do you reset it after entering test data?
2. Is it possible to start it at a number higher than 1 - for example 1000 and if so how?
3. If (2.) is not possible - what are my alternatives to achieve this?
Thanks
Andy
View 14 Replies
View Related
Feb 6, 2013
I created a table and a form. One of my tables fields is AutoNum. Each time I test the form layout, the AutoNum field increase and yet I am only testing at this stage!How can I bring back this field to zero? Where is my data stored (extension)?
View 1 Replies
View Related
May 4, 2006
I need some help creating a simple datebase to store my documents and other knowledge objects. There are two types of
knowledge objects I need to store: Documents and Questions/Answers. For this reason I have created three tables: Index,
Question, and Document.
The problems I am encountering is that the ID field in the Index Table is the Primary and relates to the ID field in the
other two tables. So basically when I am entering information it can either be a question or document. I want to create a
for so that when its a question that I am entering it records the information in the question table and when its a document
I am entering it records the information in the document table.
I'm a beginner at using access and don't know VB or SQL. Any help would be appreciated.
Table Structure
Index Table
ID (Primary Key)
Link
Type
Source
Reference
Question Table
ID (Foreign Key)
Question
Answer
Document Table
ID (Foreign Key)
Title
Summary
Notes
View 1 Replies
View Related
Apr 26, 2006
Please forgive me if I don't explain everything properly, I am relatively new to Access.
I have two tables with the following information:
VOLUNTEER
PK: volunteer_ID (autonumber)
name, address, school, etc
SCHOLARSHIP
PK: scholarship_ID (autonumber)
description (text)
amount (currency)
FK: volunteer_ID (number)
One scholarship can be awarded to only one volunteer.
I have a form to enter all the volunteer information. At the bottom of the form, I would like to place a button to open a new form to award a scholarship to this volunteer. I believe I need to link the forms in the following manner:
VOLUNTEER.volunteer_ID = SCHOLARSHIP.volunteer_ID
The problem is this: The forms are not linked properly because in order to assign a volunteer to a scholarship, the scholarship must already exist. So when I click the button to open the scholarship form, the scholarship form is empty and the volunteer_ID defaults to "0".
I think this could be fixed by somehow making my button create a new scholarship_ID in the scholarship form and THEN linking the volunteer_ID fields.
Does this seem like a solution? If so, how would I implement it? I have a screenshot to help. Thank you in advance for your help.
View 6 Replies
View Related
Jan 17, 2005
Hello,
I am starting to get further into access development, originally i started from a sample database and have been teaching myself as i go along. This database has come pretty far and the farther it comes along the more my company demands of me from it!
either way, it is basically a database that holds all of our asset information, equipment parts, workorders and preventative maintenance. We've been plugging along just fine but I want to help their productivity and have access automatically create "Equipment ID"'s from information that is entered by the person adding an asset. I would like it to create an ID from Entry of the Department, Location, and then a 4 digit Autonumber after that.
Basically we have a few basic departments, IT, Facilities, etc. and a few locations... So we have been setting our equipment ID's like this:
AA - Two characters for the Location
BB - Two characters for the department
0000 - numbered field
So I really would like to be able to create these automatically instead of manually typing them in to a text field with an input mask.
AABB-0000 to automatically create entries from the departmental info, location info and then automatically create a 4 digit number in order to follow it.
What is the best way to do this? Keep in mind I am just barely able to do any code, I only have been going from what i see in the database and building upon it and learning a few bits and pieces of code from there. So if you start going into a code explaination go slow~!
Thanks,
Jim
View 4 Replies
View Related
May 8, 2013
I have a database that I will use for invoicing, but I would like it to automatically create an invoice for customers based on parameters set for that customer (e.g., monthly, biweekly, etc.). I have tables containing the customer information, the item they are being billing, the price, etc. I want to be able to have access automatically create the invoices and add them onto the invoice table each month.
Maybe there is a better way, but I thought that if I created a query for all people that are billed biweekly and all people that are billed monthly, that I could run the queries when applicable and then somehow write a macro that would go through the list of customers and add each of them to the Invoice table and add an autonumber. That way I could click run query, run macro, and then do my invoicing. I don't know if that is the way to go or not.
View 8 Replies
View Related
Aug 25, 2006
Is there a way to just select like through a find dialog box, the location of a databases backend location and just automatically create all the links for the link tables...
The reason Im asking, is my boss wants the database to be on his laptop in the event that the network is down, and also so that he can work away from the company's location but I was showing him the implications of having it installed locally on his machine should his laptop go down....
So now I'm wondering if i could
1. do some automation that allows him to just choose the location of the databases backend that he would be working from, be it on the network or on his machine
and
2. using both backends to update or overwrite each other depending on which he was working from or did updates to..
Really would love all the help and input I can get on this... Im willing to work on developing a sample for this if nothing is exactly already out there so that it can be reposted cause i think this would be very useful to everyone's database applications.
View 1 Replies
View Related
May 10, 2013
I am hoping to create a field name in a query that will change every month. Right now the filed name is qryTechQuintileMonth-7.am_quintile. this designates that the data is for October 2012. There are 6 other fields named similarly for Nov 2012 through April 2013.
Is there a way to name these fields with the proper month-year (mmm-yy) so they automatically update each month?
View 4 Replies
View Related
Sep 15, 2006
I have created a very simple Access database with a CompaniesTbl, ContactsTbl and CallsTbl. The database is used to record telesales contact with customers. The tables are set up like this:
The CompaniesTbl has an AutoNumber Primary Key field called CompanyID.
The ContactsTbl has an AutoNumber Primary Key field called ContactID and a foreign key called CompanyID.
The CallsTbl has an AutoNumber Primary Key field called CallID and foreign key called ContactID.
The relationships are set up in the relationships window and referential integrity imposed.
Twice now, while editing a contact record, an error has occured. Task Manager has had to be used to get out of it. The error is either a 'run-time error with a message that does not mean anything' or it says 'unrecognized database format' (!?).
If you open the database again the ContactID field in the Contacts Table is no longer a Primary Key field. If you look in the relationships window - the relationship between the Companies and Contacts tables no longer exists.
Any ideas much appreciated.
View 5 Replies
View Related
May 20, 2015
I am creating a database for creating quotations. The quotation number is generated using the date, for example the first quote today would be quote number "05202015-1" because it is the first one today. The next quote today would be quote number "05202015-2" and so on. Is there a way to make access automatically generate these quote numbers based on the date?
View 3 Replies
View Related
Nov 12, 2007
Hi,
May I know how do I go about getting the last value of the primary key that I get inserted? I need this PK to link the parent and child tables together.
Thanks for any valuable help!
View 5 Replies
View Related
Feb 27, 2005
Hello
I have a problem with a primary key. A table called relaties has a column relatienumber with date type: number, which is also the primary key. When a button is pressed, a function searches info from the table relaties.
The problem is the following: I figured out that when i remove the primary key constraint from the column relatienumber and save the table. the function doesn't work anymore, also when i remake the primary key for this column. How is this possible, because i changed nothing futher.
This is important because i want to change to access db to mssql db and in mssql the function also doesn't work.
It has something to do with this primary key constraint, i think :)
Who has the info???
View 3 Replies
View Related
Nov 4, 2005
Is it important that primary key would be a number for performance purposes?
How do I set 2 different fields as one primary key?
How do I set 2 different fields as two separate primary keys?
View 2 Replies
View Related
May 30, 2006
when defining tables, i normally set an autonumber as a primary key. However, i am working on a particular table, and i would like that no record will have identical values, in three particular fields
aaa bbb 123
aaa ccc 234
ddd fff 555
aaa bbb 123 <- i want to prevent this since a record with those three values already exists
Shall i set these three fields together as a primary key, or can i leave the autonumber as primary key and prevent such duplication in any manner ?
Thank You
View 6 Replies
View Related
Oct 15, 2007
Can a PK be a calculated field?
I want to be able create a PK that consists of three strings being added together. The first two would be collected from cascading combo boxes. The third field is a simple text field.
I would then run DLookup to make sure the final string is unique.
I have reasons for not using an autonumber field (there are compatibility issues with existing tables from a much older dbase database).
View 11 Replies
View Related