Dear Viju:
There is a system I use for numbering detail rows, such as within an
invoice. However, is is not based on when each row was added.
Rather, it allows the user to insert a new line anywhere within the
invoice, and allows them to move the lines around.
Here's a brief description. The InvSeq column that sorts the rows
within an invoice is an 80 character long value. The first four
characters are actually a 4 digit sequence value that is used only if
a new row is added to the end of the invoice. The other 76 characters
are used to subdivide the row sequence if a new row is inserted
between existing rows.
When a new row is inserted between two existing rows (or before the
first row) I use the characters 0-9 and A-V in these 76 characters.
This is a total of 32 character values which works out well as it is a
power of two, and therefore easy to split in half. So, I put in a
value that is exactly half way between the row preceding it and the
row following it.
For example, when inserting a new row between '000100000000 . . .' and
'000200000000 . . .' (that is, an invoice where two rows have been
added at the end of the list) the new row gets '0001G000000 . . .'
Then, if a new row is inserted between '000100000000 . . .' and
'0001G0000000 . . .' it would be '000180000000 . . .'
Each inserted row divides neatly between the preceding and following
rows. No renumbering of other rows is necessary to accomodate this.
Each of the 76 digits may be subdivided 5 times before it needs to
begin using the next digit. So, you can insert repeatedly at the same
point 380 times before it fails. This has always been enough in
practice.
I point out this moderately complex, but workable solution, so you
will see this is a real world problem of not insubstantial
proportions. However, if all you allow is the addition of a new "last
row" to an invoice, simply numbering them would work. Just get an
aggregate MAX() of the line numbers used in a given invoice and add
one to that. Or, use a date/time stamp.
The same thing can be done using number values, but the largest
numeric datatype cannot come close to the number of ordered
combinations in an 80 character width like this. In addition, if more
than 380 subdivisions became necessary, it is easily extensible for
more resolution.
Dear Tom,
Thank you for the response. I will explain my
problem a little more. I use two tables, INVOICEBILL &
INVOICEITEM to store the Invoice Data. INVOICEBILL has
the details ,InvNo, Date, CustomerId etc ..INVOICEITEM
has the details InvNo, ItemCode, Qty, SalesPrice..etc. An
operator enter Items in the invoice in any order. I
thought it will be better if I display those in the same
order (Order here doesn't mean an ORDER in query) as he
entered when he chooses to view an old invoice. Now it is
working OK and I am not sure whether this is a good
method or not!! I could have used a SLNo field and I
could have displayed items in the Invoice in the order
of SLNo. Now, InvNo in the INVOICEBILL is unique, But
InvNo in INVOICEITEM is not and I display invoices in a
VB Flex Grid, where I can put SlNo's very easily. I just
Select all Items from INVOICEITEM whose InvNo='111' (for.
eg.) . Now I wanted to display those items in a
datareport. I just wanted a column which can display
RowNo's so that I can put SlNo's in the report. Is there
any method? Or I have to change the design to Include an
additional field such as "SLNO"?
Thanking you,
VIJU.
-----Original Message-----
Dear Viju:
"I wanted to list Items in the Order I entered the Invoice"
Do you keep track of this Order in any fashion? Are you Invoice
numbers assigned sequentially? Do you keep a date/time stamp in the
Invoice table? And, if you do, is this guaranteed to be unique?
If this Order is important, then your table design needs to keep track
of it in some fashion. That is because Access does not do this for
you.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts