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

Defining automatic primary key

2
Hi all,

I've been fiddling around with creating a new database (Access 2003, Windows XP) for work the past two weeks and am having trouble defining my own customized (yet still automatic) primary key.

I have three different tables that need data inputted (Clients [P], Complaints [C], and Queries [Q]) and need individual primary keys for each that are easily identifiable by the first letter and indicative year.

I was hoping for something along the lines of P08/, C08/, Q08/ etc... then have the record number after it.

I've tried making the list in an external program and linking it - doesn't work.
Tried making a separate table to link to it - doesn't work.

I'm not sure if making a new row for 'pre-primary key' would work - since I need to report on the full number (my pre-key and the automatic key combined).

Is there any way I can do this? I've been scouring the internet for any info for hours now and my eyes are starting to blur ;)

Thanks for any help. This isn't urgent but was hoping to get this database finished and out of my hands by next week if possible.
Mar 28 '08 #1
3 1753
Dököll
2,364 Expert 2GB
Hi all,

I've been fiddling around with creating a new database (Access 2003, Windows XP) for work the past two weeks and am having trouble defining my own customized (yet still automatic) primary key.

I have three different tables that need data inputted (Clients [P], Complaints [C], and Queries [Q]) and need individual primary keys for each that are easily identifiable by the first letter and indicative year.

I was hoping for something along the lines of P08/, C08/, Q08/ etc... then have the record number after it.

I've tried making the list in an external program and linking it - doesn't work.
Tried making a separate table to link to it - doesn't work.

I'm not sure if making a new row for 'pre-primary key' would work - since I need to report on the full number (my pre-key and the automatic key combined).

Is there any way I can do this? I've been scouring the internet for any info for hours now and my eyes are starting to blur ;)

Thanks for any help. This isn't urgent but was hoping to get this database finished and out of my hands by next week if possible.
Hello EllieT!

Would you like to add your VBA code for a closer look?

Sorry for your troubles!

Dököll
Mar 28 '08 #2
EllieT
2
Hello EllieT!

Would you like to add your VBA code for a closer look?

Sorry for your troubles!

Dököll
Hi Dököll and thanks for helping.

I just went into the Visual Basic screen but its blank (can't click 'view code' or anything) :/ I haven't fiddled with the DB in the VBA coding area as yet (just design/database areas) - that's why I thought I must've been missing something.

Cheers,
Ellie
Mar 28 '08 #3
Do you want the record numbers to be automatically generated too? If so, you would add that into a COMPOSITE key. This is how:
First, in your table, setup a key called (for example) fldRecordNum with a type of Autonumber. Next, setup a key called fldType as a string data type and another called fldYear that is an integer. You then click on the outer left bar to highlight all three at once and click the little key in the toolbar that indicates they are now a "primary key."

Set the default property of the fldType to a C or P or whatever and the fldYear to the currentyear.

I might add that this is a difficult key to work with and although it might seem easier to you from an enduser perspective, it won't be that easy from a developer perspective. Why can't the enduser just read the title of the primary key, that shows up in the column, for example, "PersonnelID" or "DogOwnerID" to know which one he/she is referring to? What does the date embedded in the key mean? Is that the date that the person started or that something happened? Why not just have a field with this date in it that you reference when you build queries? And I'm really curious as to why you are building a table called "queries" unless you are building metadata. It sounds like you are coming from the perspective of someone who has worked with large flat files, like those in a hospital or something. If this is the case, I would encourage you to really get the definition of "relational database" down before I attempted to build anything. It will save you muii headaches later.
Mar 28 '08 #4

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

Similar topics

10
by: Paulo Jan | last post by:
Hi all: Let's say I'm designing a database (Postgres 7.3) with a list of all email accounts in a certain server: CREATE TABLE emails ( clienteid INT4, direccion VARCHAR(512) PRIMARY KEY,...
1
by: Mark | last post by:
Here is a description of automatic client reroute in DB2 V8.2 "The automatic client reroute feature allows client applications to recover from a loss of communication with the server so that they...
1
by: praz | last post by:
Hi, I am trying to import a delimited text file using a macro. The problem is i am not able to generate a Primary key (Let access add primary key). I have tried saving the import specs using the...
1
by: Benny | last post by:
Hello experts, Currently I am writing a database web application using viusal studio .net with C#. Just wondering when come to the database design, what are the pros and cons about setting...
0
by: Mark A | last post by:
A consultant has recommended to us that we use virtual IP addresses for our HADR databases (the virtual IP address is moved when the primary database is moved to other server), even though...
2
by: Laurence | last post by:
Hi there, Anybody knows should I also implement Automatic Client Reroute if I did HACMP and DB2 HADR on AIX? Thanks in advance,
6
by: Spiro Trikaliotis | last post by:
Hello, in a project, I stumbled upon code like follows (incomplete): #if defined(MINIXVMD) || defined(MINIX_SUPPORT) || defined(__VBCC__) || (defined(__BEOS__) && defined(WORDS_BIGENDIAN)) ||...
7
by: CodeGunnerLev1 | last post by:
Good day guys... I must say this forum is quite of useful one. I really appreciate what you guys are doing and I hope it will continue on. I have few questions that needs some help. 1. I want...
10
by: hummingbirdlj | last post by:
I have a couple questions about setting up automatic client reroute. First, after setting the alternate server for a database, is there a way to verify the settings later on? The next thing is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.