Results 1 to 5 of 5
  1. #1
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317

    Creating serial numbers for non-distinct records

    Folks



    I have a real puzzle to deal with. I need to select records from a 'view' that contains several memo fields but no unique key. Here's a simplified version of what I'm faced with:


    View
    Shape Colour Info
    Round Red <256+ characters>
    Round Red <256+ characters>
    Square Blue <256+ characters>


    Required output
    Shape Colour Info
    Round Red <256+ characters>
    Square Blue <256+ characters>


    The first thing to mention is that it doesn't matter which of the Round-Red records I select. But the problem is that I can't use FIRST, MAX, etc. without Access truncating the memo field for reasons of efficiency. What I could do with is a means of selecting a completely arbitrary Round-Red record so Access doesn't have to examine the contents of the memo field.

    I've thought of starting by creating, through a query, a column of arbitrary serial numbers, but all methods of doing this seem to require a unique key, which I don't have.

    Any ideas?

    Remster


    EDIT: Apologies for the misleading title of this thread, which made sense when I started writing the original post!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Tell us more about your table structure and about the database generally.
    You have no Primary Keys??

  3. #3
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    It's an external database that we have an ODBC connection to (if that's the right way to put it). Unfortunately, we can access only views and not the underlying tables – which presumaby do have primary keys.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    My first reaction was to find out if you can have Access with ODBC to tables without PK. I remember years ago that I could not link tables with Lotus Approach without a PK.
    Anyway, you can, I found this link.

    Is this required for this session only? And there is no requirement to match these "possibly existing pks"?

    Create a local table with an autonumber id field, and the fields in the view. Read and append your records from the view into the local table. Now you can separate records based on the ID field. Use your local table for processing.
    Last edited by orange; 02-18-2015 at 11:03 AM. Reason: spelling

  5. #5
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    Coincidentally, the solution I've come up with is the one you propose:

    1. Change the problematic select query to a make-table query for creating the table structure – I'll call this 'tblAllData'.
    2. Run the make-table query.
    3. Add an autonumber ID field to tblAllData and change the data type of the memo field to 'memo' (Access will have set it to 'text' and removed any characters after the 255th).
    4. Change the make-table query to an append query – 'qryAppendNew'.
    5. Create a delete query for deleting all records from tblAllData – 'qryDeleteOld'.
    6. Create a select query based on tblAllData to select the first ID per non-unique reference number – 'qryUniqueReferences'.
    7. Create a select query based on tblAllData and qryUniqueReferences to select all records from tblAllData where both the ID and the non-unique reference number match those in qryUniqueReferences – 'qryUniqueRecords'.
    8. Run qryDeleteOld.
    9. Run qryAppendNew.
    10. Run qryUniqueRecords.

    Bingo!

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

Similar Threads

  1. Adding serial numbers to reports automatically
    By Ayiramala in forum Access
    Replies: 2
    Last Post: 12-18-2014, 10:29 AM
  2. Help with Serial numbers table
    By RandyP in forum Programming
    Replies: 2
    Last Post: 06-11-2014, 03:39 PM
  3. mutli serial numbers in one
    By wirelineuk in forum Queries
    Replies: 1
    Last Post: 10-11-2012, 01:26 PM
  4. Automatic Serial Numbers
    By Mitch87 in forum Access
    Replies: 9
    Last Post: 02-18-2010, 12:57 PM
  5. organizing serial numbers and quantities
    By Diomeneus in forum Access
    Replies: 0
    Last Post: 11-14-2008, 03:17 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