adlockpessimistic

R

Roopesh babu

i have an access database
i want to update a value in a table in this database
so that this new updated field will be unique

but when more than one users are using the same
table duplicate values are being updated plz advice

i am using adlockpessimistic


plz see the coding

Function Get_Last_Counter(ByVal cn As ADODB.Connection, Optional Temp_Flag
As Boolean = False) As Boolean
Get_Last_Counter = False
On Error GoTo ErrHdlr

Dim m_strSql As String

Set m_rsCounter = New ADODB.Recordset

m_rsCounter.CursorLocation = adUseServer

'm_rsCounter.CursorLocation = adUseClient

'cn.Mode = adModeShareExclusive

If Temp_Flag = True Then
m_strSql = "Select Temp_Next_No as Document_Next_No, Last_Update
From Document_Prefix Where Document_Prefix='" _
& m_Document_Prefix & "' and Company_Prefix='" &
m_Company_Prefix _
& "' and Branch_Prefix='" & m_Branch_Prefix & "'"
Else
m_strSql = "Select Document_Next_No, Last_Update From
Document_Prefix Where Document_Prefix='" _
& m_Document_Prefix & "' and Company_Prefix='" &
m_Company_Prefix _
& "' and Branch_Prefix='" & m_Branch_Prefix & "'"
End If

m_rsCounter.Open m_strSql, cn, adOpenDynamic, adLockPessimistic ',
adCmdText
If Not m_rsCounter.EOF Then
If m_rsCounter.EditMode = adEditInProgress Then
GoTo ErrHdlr
Exit Function
End If

m_rsCounter!Last_Update = Now
m_Next_Document_No = m_rsCounter!Document_Next_No

Get_Last_Counter = True
End If
Exit Function

ErrHdlr:
m_ErrDesc = Err.Number & " - " & Err.Description
End Function

even if one user have already opened this database.
a new user can open it.
 
Top