I need to use MTS and also create unique numbers in a database so that it is hopefully unique for any process attaching to it. However I
can not seem to be able to do this.

I am using Access (SQL Server and Oracle can supposedly automatically produce this) but access can't do it.

The following function grabs a record and adds one after a specified number
of seconds.

I can fire off 2 apps using this MTS function. App 1 is set to 10 second
delay and app 2 is zero delay. App 1 grabs a number, then App 2 grabs a
number and App 2 inserts the new one. App 1 then tries to insert the same
value.

How can this be over come.

Thank you

David

Public Function Test(N As Integer) As String
Dim oContext As ObjectContext
Set oContext = GetObjectContext
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Conn.Open "Driver={Microsoft Access Driver
(*.mdb)};DBQ=hr.mdb;DefaultDir=F:\HR;Uid=Admin;Pwd=;"
Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset
Conn.BeginTrans
RS.Open "SELECT MAX(ID) FROM tTest", Conn, adOpenDynamic,
adLockPessimistic
Dim nID As Long
nID = RS(0) + 1
Dim strSQL As String
Dim Start
Start = Timer
While Timer < Start + N
DoEvents
Wend
strSQL = "INSERT INTO tTest (ID) VALUES (" & CStr(nID) & ")"
Conn.Execute strSQL
RS.Close
Set RS = Nothing
Conn.CommitTrans
Conn.Close
Set Conn = Nothing
Test = CStr(nID)
'Test = "Completed"
If Not oContext Is Nothing Then GetObjectContext.SetComplete
End Function