Here is a function that can work: Put this in a public module:
Public Function NextNumber(varF ield As Variant, Optional varValue As
Variant) As Long
Static lngNextNumber As Long
If IsMissing(varVa lue) Then
lngNextNumber = lngNextNumber + 1
Else
lngNextNumber = varValue
End If
NextNumber = lngNextNumber
End Function
Then "prime" the function with a starting value by executing this from
the Immediate window:
call NextNumber("Som eValue",0)
Finally, add a column to your query like this:
RowNumber: NextNumber([SomeFieldInQuer y])
(field name is REQUIRED, but not significant -- any one will work)
On Mon, 13 Feb 2006 22:40:40 -0000, "John" <Jo**@nospam.in fovis.co.uk>
wrote:
Hi
I need to assign sequential invoice numbers to orders starting from the last
highest number + 1. I have tried the following code;
UPDATE Orders SET Orders.[Invoice No] = DMax("[Invoice No]","Orders") +1
WHERE Orders.[Invoice No]) Is Null AND ...
The problem is that all orders get the same number which is the last highest
number + 1. Apparently the query does not recalculate DMax("[Invoice
No]","Orders") +1 for each record and instead only gets the value once in the
beginning and assigns this same value to all the records. How can I make it
work?
Thanks
Regards
*************** *******
ja************* *@telusTELUS.ne t
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security