Results 1 to 5 of 5
  1. #1
    deanslgr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Detroit, Michigan
    Posts
    3

    Need to create a new unique identifier in sequence to existing IDs

    I oversee an Access database that was developed before my time by someone who is no longer with the company. The DB holds patient records on inpatient stays. For the past year and a half we only been getting records from a single source, where they assign a patient ID before sending us the patient records. Our database was built around that patient ID. There are several interactive forms and tables in the DB all revolving around that ID (rebuilding the DB is not an option). We have started receiving records from other sources that need to be added to the database, however I need to figure out an automated way to create an ID for those new patients.



    The new data are imported from Excel spreadsheets.

    After reviewing several threads on this board, I thought maybe I could use the DMAX function to create the new IDs. So I created a master table of all the unique patients and their IDs.

    My first attempt was to try an append query appending the data from the spreadsheet into the master table:

    New_ID: DMax([PATIENT_IDENTIFIER],"PATIENT_IDENTIFIER_NUMBERS")+1

    This worked for the first patient in the spreadsheet, but then it added that person to the master table a thousand times each with a newly created ID.

    So then I appended the new patients into the master table leaving the ID blank and attempted an update query:

    Update to: DMax([PATIENT_IDENTIFIER],"PATIENT_IDENTIFIER_NUMBERS",[Patient_Identifier_Final] Is Null)+1

    I created a second field in the master table, "Patient_Identifier_Final," to fit the 'null' criteria. If I said where PATIENT_IDENTIFIER is null I didn't think that would work because that is the field where the query is getting the max ID from. This, however, did not work.

    So now I am at a brick wall. The DMAX might not be the way to go, but I cannot find any other way of doing it.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Review recent thread on this same issue https://www.accessforums.net/queries...ers-33632.html

    There is always VBA code option.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    deanslgr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Detroit, Michigan
    Posts
    3
    Thanks, but I read those threads and they involve forms. I'm not using a form. The new patients are being imported into the database 30-40 a day via Excel spreadsheets. So I need to know how to create an ID either during the import/append process or via an update query.

    What would be the VBA option?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That entire thread discusses updating a table with a unique identifier. Form objects are not involved. Only one post references another thread which had no bearing on the solution.

    VBA would open a recordset, loop through records, set value of ID field for each record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    deanslgr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Detroit, Michigan
    Posts
    3
    OK, yes, you are correct. The thread https://www.accessforums.net/queries...ers-33632.html is not about forms. However, I am not seeing a solution to my problem. I have a series of numbers. I am not concatenating any fields. If I adapt your update code to Format(DCount("*","Table")+1,"000") all I get are 193 records all with the Patient ID of "194."

    So I guess what you are telling me is that I need to find a VBA, not an Access, forum.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Unique Identifier beginning with "00"
    By dsaxena15 in forum Access
    Replies: 5
    Last Post: 02-05-2013, 09:44 PM
  2. Replies: 5
    Last Post: 08-02-2012, 08:49 AM
  3. Using Social# as unique identifier
    By NEHicks in forum Database Design
    Replies: 3
    Last Post: 05-27-2011, 09:14 AM
  4. Restoring a lost field with a Unique Identifier
    By DBinazeski in forum Access
    Replies: 5
    Last Post: 12-20-2010, 08:02 AM
  5. Unique Record Identifier for MS SQL Server Tables
    By MGSP in forum Import/Export Data
    Replies: 2
    Last Post: 01-29-2006, 03:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums