Neither of those indexes would be unique. It would also be almost impossible
to get a match on the numbering. The prefix is year only. The month and day
would only confuse the issue. I would not design a system where it takes two
fields to carry one piece of data.
I think will will have to agree to disagree on this.
> > First, there is no date field. It would need to be either Long (or
> > Integer) or Text.
[quoted text clipped - 15 lines]
> DateTime field and a Long Integer field and would have indexes on eqch of them.
> Then the calculation for next number could be set up to use both indexes.
> Neither of those indexes would be unique.
Why would uniqueness be a requirement? My point was only that if you apply
criteria in a domain function against an expression then you always get a table
scan. If you instead apply criteria to indexed fields then the indexes can be
taken advantage of.
> It would also be almost impossible
> to get a match on the numbering. The prefix is year only. The month and day
> would only confuse the issue. I would not design a system where it takes two
> fields to carry one piece of data.
Most records can benefit from a CreatedOn DateTime field. This same field could
be utilized to produce the proper prefix numbering merely by using the Format()
function.

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Klatuu - 15 Dec 2005 00:26 GMT
Are you saying that a non unique index would give you better performance a
domain expression?
> > Neither of those indexes would be unique.
>
[quoted text clipped - 11 lines]
> be utilized to produce the proper prefix numbering merely by using the Format()
> function.
Klatuu - 15 Dec 2005 14:33 GMT
Rick,
I have thinking a lot about this discussion. I save advantages and
disadvantages to both of our ideas. I have come up with a concept that uses
one field, but also has the advantage of being able to use an index where the
values are unique.
lets say we want to have the year as two digits, a dash, and a three digit
number. As we both know, how we carry data and how we present the data are
not necessarily the same, so. let's take the year, multiply it by 1000 (one
zero for each unique number). So the first number would be 05-001. To
create a unique number:
(Clng(Format(Year(Date),"yy")) * 1000) + 1
will result in 5001
Then to display it:
Format(x,"00-000")
will result in 05-001
Now, to fin the maximum for the current year:
lngFindValue = (Clng(Format(Date,"yy")) + 1) * 1000
' Now we have 6000
DMax("[DOC_NUM]", "MyTable", "[DOC_NUM] < " & lngFindValue)
I would appreciate your thoughts on this approach.
> > Neither of those indexes would be unique.
>
[quoted text clipped - 11 lines]
> be utilized to produce the proper prefix numbering merely by using the Format()
> function.