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

Unique ID

Status
Not open for further replies.

harrysdad

Programmer
Joined
May 30, 2002
Messages
53
Location
GB
I want to create a unique ID, perhaps based on information provided in a web form, eg maybe combining parts of a name with a date. This is for a web application, so it could be generated in asp or maybe in access (not sure).

Any pointers on how this can be done?

Regards

Tony
 
If you want to use portions of user entered values to make the ID, I would to the least suggest a random number concatination to possibly the anme value they enter.

I recommend not using user entered values to create a identity though. relational structures should take the need for that out of the picture and prevent errors in what the identity key is for.

_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
I agree with GaryC123, the autonumber field is the best choice. If you use a randomly generated id, there is a chance, no matter how slight, that the value will duplicate. Of course, you could generate a random number and then check to see if it's already been used. But why do all the extra work? Apply the KISS principle and you'll be good to go.
 
[tt]
This may get your ideas going...

Back in march (at my previous job) I was asked to create a webpage where internal users would create entries to this new log system where the id created to identify each entry would include the month/year/initials/increment numbers.

Here's a sample of what I came up with. (with help from TT members):




<%
curDate = Now()
bidyy = Year(curDate)
bidmm = Month(curDate)
bidui = request.cookies(&quot;user&quot;)(&quot;initials&quot;)
if len(bidmm) = 1 Then
bidmm = &quot;0&quot; & bidmm
end if
'response.write bidmm

Dim rsNewbidnumber
Set rsNewbidnumber = Server.CreateObject(&quot;ADODB.Recordset&quot;)
sql = &quot;Select bidnumber from MYDB Where bidnumber like '&quot; & bidyy & bidmm & &quot;%' and initials = '&quot; & bidui & &quot;'&quot;
rsNewbidnumber.open SQL, &quot;dsn=MYDB;uid=MYID;pwd=MYPASS;&quot;

if rsNewbidnumber.eof or rsNewbidnumber.bof Then
bidfullnumber = bidyy & bidmm & &quot;001&quot;
else
bidfullnumber = rsNewbidnumber + 1
end if
%>
<%
'response.write bidfullnumber
%>


google.gif
And for additional ASP answers, download a 900+ page PDF here: thread333-721855
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top