Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting next record number

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I am using the following to get the next invoice number.
Code:
	SELECT FRAMES
	SET ORDER TO INVNO
	GO BOTTOM
	TOP_INVOICE=FRAMES.INVNO
	TOP_INVOICE=TOP_INVOICE+1

It works fine on my computer but on my client's computer, TOP_INVOICE is sometimes set to the value of 1, rather than the highest invoice number+1.

Any thoughts?

Keith
 
Another things speaks against APPEND BLANK not being the culprit: 1. Even if that record is written GO BOTTOM goes to bottom in index order, not to the record with highest recno.

A thing that could turn the index sorting from ascending to descending is a grid implementing sorting in it's header click, using indexes and SET ORDER TO with ASCENDING or DESCENDING. So as an example: If a user last sorted a list to descending invoice numbers, this can turn the next invno creation wrong, no matter how much time ago that has been done.

Bye, Olaf.
 
Descending() (the function) has had issues as well in various versions.

There was one version where Descending() would return the value for the last SET ORDER statement for *any* table, not the current table or current order.

It's one reason I avoid descending indexes. <g>
 
May be buffering problem with network, add Locate statement after setting the "SET ORDER TO ..."
 
You're relying on an index to get you to the last invoice generated... not a good practice due to the possibility of the index not being in sync with the data table or being corrupted...

Code:
local ln_invno
ln_Invo = 0
select distinct invno from frames into cursor tmpFrames
scan 
ln_Invno = max(ln_invno, invno)
endscan
return ln_invno

Andy Snyder
SnyAc Software Services Hyperware Inc. a division of AmTech Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top