Results 1 to 3 of 3
  1. #1
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83

    Preserving the order of Excel file without an ID field

    A CSV file has been converted into .XLS file using VBA code in Access and an Excel object.

    Access imports the file. Excel has done nothing to it except change the format to XLS. So I'm ready to use VBA to start using the data, but the order of items in that file is critical, and when I do a query (openrecordset) Access will scramble the order of items... is there a way around that? The file comes in with many rows but just the one column.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If you are importing the file into Access, let Access add an Autonumber Primary Key field. Then, if you use this field to sort by, it will keep the records in the same order as they were on the original file.

  3. #3
    togo is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    83
    haha. Solved the issue, wasnt hard at all

    appExcel.Workbooks.Open strCSVPath, , , 2

    2 specifies comma delimited, then save it

    appExcel.ActiveWorkbook.SaveAs FileName:=Left(strXLSMPath, Len(strCSVPath) - 3) & "xlsm" _
    , FileFormat:=52

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

Similar Threads

  1. Import from Excel. Order of RTL string and number are changed
    By MichaelAgan in forum Import/Export Data
    Replies: 1
    Last Post: 08-20-2012, 02:02 PM
  2. Replies: 6
    Last Post: 11-05-2011, 09:01 AM
  3. Replies: 1
    Last Post: 06-16-2010, 09:25 AM
  4. Replies: 6
    Last Post: 05-11-2010, 02:22 PM
  5. Fields order changes on sending to excel
    By captgnvr in forum Import/Export Data
    Replies: 1
    Last Post: 10-01-2009, 09:29 AM

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