Results 1 to 2 of 2
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Append query + VBA not appending in order i chose!

    Hi ppl,



    There is a reason for this. its not "100% needed" but even if not i want to learn what is going wrong!

    SO i have a list of items with ITEMID and Item NAME

    I was looking to copy that table, reorder it in alphabetical order and then re-number it.

    Therefore

    1. Banana
    2. Apple
    3 Mango

    would get reworked to be

    1. Apple
    2. Banana
    3. Mango

    (as an Aside, as this occurs i have a new table being created to link the old and new ItemID)


    Once again... i know this sounds weird (eg WHY ARE YOU CHANGING THEIR PRIMARY KEY OF ID) but there is a reason... and its a long story :P


    SO.

    What I have is an APPEND query which is sorted in ascending order of ITEMNAME

    When i look at this query, it looks correct. All 2000 items are in order

    in VBA i do this:
    Code:
    'Export Items
    DoCmd.OpenQuery "QuItemCreator"
    CurrentDb.Execute "ALTER TABLE TmpLinkItems ALTER COLUMN [LogikItemID] NUMBER"
    CurrentDb.Execute "ALTER TABLE TmpLinkItems ADD [ItemID] AUTOINCREMENT PRIMARY KEY NOT NULL"
    
    
    DoCmd.OpenQuery "QuUpdateItemLink"
    Therefore it changes the current auto primary key to just NUMBER and then adds a new ITEMID Key in auto increment.

    THIS WORKS.

    But for some reason it then loses its ordering and starts from items in the AS section of the alphabet... so it now is no longer correctely ordered... or more commonly, the first 200 items are put further down the table!??

    I hve NO idea why this is occuring but can anyone help me out here?

    On another nte, every time i run the code it runs DIFFERENTLY and different items are in order!!!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you specified the order of the data in a query?

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

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2016, 05:02 PM
  2. Access can't append all the records in the append query
    By fluffyvampirekitten in forum Access
    Replies: 2
    Last Post: 08-27-2015, 01:53 AM
  3. Replies: 1
    Last Post: 03-13-2013, 10:37 PM
  4. Replies: 1
    Last Post: 10-06-2011, 08:37 AM
  5. Replies: 7
    Last Post: 07-21-2011, 01:01 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