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

AutoNumber

Status
Not open for further replies.

wdu94

Programmer
Aug 15, 2001
61
0
0
US
Hello,

I have the ShopOrderNum need to be autonumber.

The oringal number like

ShopOrderNum
----------------------
0001-0
0001-1
0002-0
0003-1
....

how to get autonumber like that:

ShopOrderNum
-------------------------
0001-0
0001A-0
0001B-0
0001C-0
...
0001-1
0001A-1
0001B-1
0001C-1
....

0002-1
0002A-1
0002B-1
0002C-1
...

0003-1
0003A-1
0003B-1
0003C-1
0003D-1
....


The case is:

An automated numbering system for a multiple-part order needs to be created, so that when a new order is entered, the next available number comes up; then, if there is more than one part to an order, each part will get a letter (A, B, C, etc.).


The following are my codes but doesn't works for me.

Thanks and hppy a Thanksgiving day.

Wdu

Option Compare Database

Public Function AsciiNumber(ShopOrderNum As String) As String
Dim intChar As Integer
If Len(Trim(ShopOrderNum)) > 5 Then
intChar = Asc(Mid(ShopOrderNum, 4, 1)) + 1
ShopOrderNum = Left(ShopOrderNum, 3) & Chr(intChar) & Right(ShopOrderNum, 2)
Else
ShopOrderNum = Left(ShopOrderNum, 3) & "A" & Right(ShopOrderNum, 2)
End If
AsciiNumber = ShopOrderNum
End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top