James Dickinson
PigeonPie
- Local time
 - Tomorrow, 12:55
 
- Joined
 - May 10, 2018
 
- Messages
 - 43
 
The Test:
Confirm that DAO's LastModified function does indeed return YOUR Last Modified record.
Method:
Using 2 Access Front Ends running the same routine and connecting to a single Access Back End table.
Attempt to read back an inserted GUID value that is not the inserted GUID value.
Loop and continue if contention.
Steps:
The following code was used in a Module in the 2 Front End databases each run within a few seconds of the other.
	
	
	
		
Results:
While contention did occur at times there was no attempt that returned a failed result.
Last Modified was indeed YOUR last modified record under these conditions.
 Confirm that DAO's LastModified function does indeed return YOUR Last Modified record.
Method:
Using 2 Access Front Ends running the same routine and connecting to a single Access Back End table.
Attempt to read back an inserted GUID value that is not the inserted GUID value.
Loop and continue if contention.
Steps:
- BACKEND: Create a blank database with a table Named [Bloat] and fields [ID] autonumber and [GUID] short text
 - FRONT END: Create a blank database add a module and paste the code below.
 - Copy the FRONT END so there are 2 Front Ends
 - Link the Back End Table [Bloat] to the Front Ends
 - Run testingLastModified in both front ends
 
The following code was used in a Module in the 2 Front End databases each run within a few seconds of the other.
		Code:
	
	
	Option Compare Database
Option Explicit
Private Type GUID_TYPE
                Data1 As Long
                Data2 As Integer
                Data3 As Integer
                Data4(7) As Byte
End Type
Private Declare PtrSafe Function CoCreateGuid Lib "ole32.dll" (Guid As GUID_TYPE) As LongPtr
Private Declare PtrSafe Function StringFromGUID2 Lib "ole32.dll" (Guid As GUID_TYPE, ByVal lpStrGuid As LongPtr, ByVal cbMax As Long) As LongPtr
Function GenerateGUID() As String
10    On Error GoTo PROC_ERR
                Dim Guid As GUID_TYPE
                Dim strGuid As String
                Dim retValue As LongPtr
                Const guidLength As Long = 39
                retValue = CoCreateGuid(Guid)
                If retValue = 0 Then
                                strGuid = String$(guidLength, vbNullChar)
                        retValue = StringFromGUID2(Guid, StrPtr(strGuid), guidLength)
                                If retValue = guidLength Then
                                                ' valid GUID as a string
            GenerateGUID = Mid$(strGuid, 2, 36)  ' removes the braces from the output
                                End If
                End If
PROC_EXIT:
            Exit Function
PROC_ERR:
            MsgBox "Error: " & err.Number & ". " & err.Description
            Resume PROC_EXIT
End Function
Public Function testingLastModified()
   Dim rs As DAO.Recordset
   Dim strKnownGUID As String
   Dim i As Integer, e As Integer
   Dim DB As Database
   On Error GoTo err
   Set DB = CurrentDb
   Do
      Set rs = DB.OpenRecordset("SELECT * from [Bloat]")
      strKnownGUID = GenerateGUID
      rs.AddNew
      rs!Guid = strKnownGUID
      rs.Update
  
      rs.Bookmark = rs.LastModified
      If rs!Guid <> strKnownGUID Then
         MsgBox "Failed wrong GUID!!!!"
      Else
         Debug.Print "Pass", i
      End If
      rs.Close
      DoEvents
      i = i + 1
  
   Loop While (i < 100000)
   Exit Function
err:
   e = e + 1
   DoEvents
   Debug.Print "Contention", i, e
   Resume
End Function
	Results:
While contention did occur at times there was no attempt that returned a failed result.
Last Modified was indeed YOUR last modified record under these conditions.
	