Results 1 to 6 of 6
  1. #1
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376

    Table not indexed correctly


    Hello all, I have a very weird problem I have not seen before and I want some expert advice before I really goof things up. I have a table that all of a sudden the indexing is not right, what I mean is that the ID is not sequential like it should be. I have tried compact and repair and that has had no affect. I can get it correct by sorting on the ID column of the table but my fear is will all other data in the other columns follow that? When I do that and try to close the table it asks me if I want to save the new table design, so I choose "No". When I look at the data it does seem to follow the sort but I want to make sure.

    I have use this database with no issues until this week, I started using it from home, connecting to the Work network thru a VPN.

    Thanks in advance
    Dave

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    even with the index, you can sort the data anyway you want.
    if your index is set to no dupes, and you enter a duplicate and it saves THEN you have a problem.
    but you may be OK.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    what I mean is that the ID is not sequential like it should be.
    what is the dataype for your ID? autonumber? number? text?

  4. #4
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    The datatype is autonumber, it's the primary key. I made a backup copy of the table, it's a split database. I did try the sort on the primary key and the data did seem to follow like I had hoped, but now I had a new problem which led me to find the sorting issue. I have a form linked to that table that is set to go to the last record on load but it is still going to the last record of the unsorted table, very confusing.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    autonumbers will get gaps if you start to create a record, then abandon it. Or if you delete a record. That is normal behaviour. A primary key should have no meaning other than to uniquely identify a record - and order implies meaning - if you look at the new values property for your autonumber field, you will see you have a choice - increment (default) or random (which will include negative values)

    Data is stored in a table randomly. If it happens to present in the correct order that is just luck. If order matters you need to sort.

    The randomness is determined by a number of factors primarily involved around how the data is stored on the drive and how it is retrieved, Access (any database) will optimise the storage and retrieval process for best performance.

    my fear is will all other data in the other columns follow that
    not sure what you mean by that

    I have a form linked to that table that is set to go to the last record on load but it is still going to the last record of the unsorted table, very confusing
    last/first and next/previous are meaningless in databases without an order. It is always better to use a query as your form recordsource which you can sort as required.

    select * from mytable order by ID

  6. #6
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    Figure this one out. The form is now also working correctly after I opened it in design view, looked at the code to make sure it was set to got to the last record, closed the code window, went back to "Form" view, all was good. I closed the form reopened it and it went to the last record as expected and is working fine.

    Ajax what I meant by will the other data follow is would the other columns follow the sort of the primary key or would just the primary key column sort, I found it all did "follow" the primary key sort.

    What I meant by the form wasn't opening to the last record is that it was still opening to what the original goofed up table was which was record 173 because of the primary key sort issue. the last record was actually 1474 in the table.

    All seems to be working fine now.

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

Similar Threads

  1. Need design suggestions for indexed-no duplicates field
    By jax1000rr in forum Database Design
    Replies: 3
    Last Post: 01-29-2013, 06:42 AM
  2. Replies: 15
    Last Post: 12-10-2012, 06:37 PM
  3. Copy and Paste Data Into an Indexed Table
    By CLT49er in forum Import/Export Data
    Replies: 1
    Last Post: 01-05-2012, 03:47 PM
  4. PK field, indexed-no duplicates shows twice in query
    By jhollingsh615 in forum Database Design
    Replies: 2
    Last Post: 05-26-2011, 05:24 PM
  5. Macro for Indexed Value
    By jversiz in forum Access
    Replies: 0
    Last Post: 10-19-2007, 01:16 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