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!

Unique Autonumber Design

Status
Not open for further replies.

qad122

Technical User
Nov 14, 2002
12
0
0
US
I want to create a unique customer ID number consisting of the first four characters of the customer's last name, and then 4 random numbers. It is driving me crazy.

I have been successful in creating automatic sales ID, and product ID with the DLookup function.

Any suggestions?

thanks,

Susan
 
Code:
Function RandomDigits(NumDigits As Integer) As String
' Returns a string of random digits NumDigits (1 to 10) in length
    RandomDigits = Format$(Rnd() * 10 ^ NumDigits, String$(NumDigits, "0"))
End Function

CustID = Left$(CustName) & RandomDigits(4)
Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top