Rather than trying track the last ticket number and increment it which has to be stored somewhere reliable between when the system is shut down and restarted , i use the date and time to assign a ticket number which ensures I never get a duplicate ticket number. The ticket number is dependend on the date and time to the 6th decimal place. Depending on the expected minimum length of time between your program assigning work order nos, you can change the granularity up or down by changing the 6.
Function AssignWONumber() as string
dim dtserial as long, tmserial as double, i as integer
dtserial = DateValue(a): tmserial = TimeValue(a)
i = InStr(str(tmserial), ".")
AssignWoNumber = Trim(str(dtserial)) + Mid(str(tmserial), i + 1, 6)
exit function
Bookmarks