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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prefixing an autonumber

Status
Not open for further replies.

cobweb

IS-IT--Management
May 5, 2002
95
GB
I am trying to write a customer service database in Paradox 9.
There are several types of customer service record: CS (Customer Service) RM (Remake) RR (Remedial).

What I want is a record to generate the next number in the sequence, prefixed by the service record: ie the next CS record will be CS123, then CS124 etc; the next RM will be RM456, then RM457 etc.However, these all need to be stored in the same table; so is it possible for Paradox to find the next number in the sequence with that particular prefix?
The prefix will be defined as a separate field in the table.

Hoping I make sense!
 
I would use a seperate table for numbering and use a tCursor to increment when a new record is created.

Here is some sample code from one of my apps that uses a prefix numbering scheme. It places the resulting hyphenated number in an undefined field (jobNumber)on a form. You could put it anywhere, of course, once you define it. Being a tCursor based routine, it is almost instant.

Code:
var
 addTc  tCursor
endvar

if JobNumber.value = ""
	then	addTc.open(":buildit:numbers.db")
			addTc.edit()
			addTc.JobNum = addTc.JobNum + 1
			JobNumber.value = addTc.Prefix + "-" + strVal(int(addTc.JobNum))
			addTc.endEdit()
			addTc.close()
endif

Hope this helps,


Mac :)

"Strange women lying in ponds and distributing swords is no basis for a system of government" - Dennis, age 37

mailto:langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top