PDA

View Full Version : How to keep a table sorted with vba or vb.net??



Zrob
09-16-2010, 05:06 PM
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.

hansup
09-16-2010, 06:42 PM
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:

SELECT Max(i.invoice_id) AS MaxOfinvoice_id
FROM Invoices AS i;

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.

Zrob
09-16-2010, 06:57 PM
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:

SELECT Max(i.invoice_id) AS MaxOfinvoice_id
FROM Invoices AS i;
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!

:doh:

Thanks!