473,412 Members | 3,471 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,412 software developers and data experts.

Unique Identifier

Hello all,

I've looked on the net, and can't seem to find an answer that best suits my needs. I'm developing a package for a Doctor.
I need to use a unique identifier for all records. The primary screen will be for Adding Patients. From this table I will need to update small bits of info to various other tables. Maybe I'm being too analytical when it comes to the unique key, but I would like to know how to unstring parts of 3 fields and combine them into a new field (the Index key). All of this would be done when the user clicks on 'Save Record' at the end of the form.

Example: Patient Name is John Does, with a SSN of 111-11-1111. The key I want would be first 4 letters of FName, first 4 letters of LName, and last 4 digits of SSN for a key that would look like johndoes1111. That should fairly well eliminate the possibility of 2 patients with the same name.

I know how to do this in theory, from various other languages I've used, but not a clue in Access 2007.

Am I being too complex with the key? Or is this workable?
Sep 28 '16 #1
4 1406
PhilOfWalton
1,430 Expert 1GB
The simple way is
Expand|Select|Wrap|Line Numbers
  1. Left(FName,4) & left(LName,4) & Right(SSN,4)
  2.  
However if there are less than 4 letters in a name - John Doe for example you get JohnDoe11121

So you might want to pad it with spaces so that you always get a 12 letter result.

Expand|Select|Wrap|Line Numbers
  1. Left(FName & "    ",4) & left(LName & "    ",4) & Right("    " & SSN,4)
  2.  
"Fairly well eliminate the possibility 2 patients with the same name." is not a good option.

I assume you have a primary Key for your table - PatientID as an autonumber which is the foreign key for the other tables you mentioned

Phil
Sep 29 '16 #2
Can't believe I'd forgotten how to do that. Thanks!
Can a table have more than one key? I don't recall, and the programmer's reference I have is vague on the issue. Using the statement above:
PatID = Left(FName & " ",4) & left(LName & " ",4) & Right(" " & SSN,4)? Would this work in assigning the Patient ID? I want the data for the field created when the user clicks on the 'Save Record' key.

Was thinking about it. The last time I used Access and VB, was 15 yrs ago.
Oct 3 '16 #3
PhilOfWalton
1,430 Expert 1GB
I strongly recommend using a PatientID (AutoMumber) as the primary key.
The PatID mentioned above can also be set as a Key (No Duplicates) if you wish.

Is this number going to be of any use to anyone? If I wanted to look up a record, I would select the patient's name from a Combo Box.

Incidentally inn my original reply I had 4 spaces after the name, you only showed 1 space in your reply.

Phil
Oct 3 '16 #4
jforbes
1,107 Expert 1GB
I would agree with Phil, AutoNumber would be your best route. My biggest concern for this structure for a Primary Key is that you cannot guarantee that you would not get a repeat. If you can't be 100% unique, then you are better off using an AutoNumber and then creating a separate field that is filled in as you described.
Oct 3 '16 #5

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

Similar topics

1
by: Steve Bishop | last post by:
I would like to pass an unique identifier (UserID) to a Crystal Report from a SQL stored procedure. I found an article from Business Objects about this issue, but I couldn't get my head around it's...
8
by: Nitin | last post by:
Hello, We are trying to figure out how to get a unique identifier for a machine. Our application is a C# windows application that talks to our server via a webservice. Every time our webservice...
3
by: deko | last post by:
I have a situation where data is being imported from external tables. The Import Wizard (File > Get External Data > Import) is used to create and import tables from different sources (txt, xls,...
4
by: mpietrzyk | last post by:
Hi guys I'm having a nasty problem with bulk copying into a table that has unique identifier column. I'm coding on C++, using ODBC driver. I'm coping from a file containing UID description...
4
by: ba.hons | last post by:
Hello all, Was wondering if anyone could provide some info on what could be a possible solution to a problem am having. I have to generate a Unique Identifier in C# which I will use to assign...
2
by: Ken | last post by:
Hi, I have a form whose control source is a view from SQL server 2005 database. The view has a primary key that is a unique identifier field with keys generated by newid() function from SQL server...
8
by: DaTurk | last post by:
Hi, I was just curious how you would go about creating a unique identifier with 3 ints.
14
by: Steven D'Aprano | last post by:
I have an application that will be producing many instances, using them for a while, then tossing them away, and I want each one to have a unique identifier that won't be re-used for the lifetime...
4
by: Rob Stevens | last post by:
Is there some sort of unique identifier in every treenode that is consistent? I was looking at the handle of every treenode, but it appears that the handle changes everytime the tree is built. ...
4
by: Mufasa | last post by:
I'm looking for a way to get a truly unique identifier for a machine for our client software. I'd like to have it so that there's little or no setup by the end user. (We set up the machines and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.