Consulting

Results 1 to 3 of 3

Thread: How to keep a table sorted with vba or vb.net??

  1. #1

    How to keep a table sorted with vba or vb.net??

    Hey everyone!

    I am new to access, but I set up a table as such: a row is a record and the first cell of every row is a number that I uses such as an invoice int value, I read the last invoice value and add 1 to it and then I write that and save. Well today my table on its own decided to write up at the top??? and of course I am reading at the bottom......not good! Do you guys have any code vba or .net that will sort this data first?


    Thanks.
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    447
    Location
    A table is an un-ordered "bag of data". (See note below.) If you want the largest current invoice_id value, ask for it with a query:

    [VBA]SELECT Max(i.invoice_id) AS MaxOfinvoice_id
    FROM Invoices AS i;[/VBA]

    Note: When you compact an Access database the rows will be written in primary key order. However that ordering is not maintained for subsequent inserts and updates. So that ordering is not reliable except immediately after a compact operation.

  3. #3
    Quote Originally Posted by hansup
    A table is an un-ordered "bag of data". (See note below.) If you want the largest current invoice_id value, ask for it with a query:

    [vba]SELECT Max(i.invoice_id) AS MaxOfinvoice_id
    FROM Invoices AS i;[/vba]
    Note: When you compact an Access database the rows will be written in primary key order. However that ordering is not maintained for subsequent inserts and updates. So that ordering is not reliable except immediately after a compact operation.
    Thanks for the info, and wow I guess a "bag of data" is like saying you better sort FIRST!



    Thanks!
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •