ACC2002: Write Conflicts Are Not Reported in Text or Image Data Type Fields in a Microsoft Access Project (295169)
The information in this article applies to:
This article was previously published under Q295169 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
When two users change the same record at the same time in a Microsoft Access project or in a Microsoft Access database connected to SQL Server, a write conflict message is not received if the data type of the field is Text or Image.
RESOLUTION
Create custom code that uses form events to check for write conflicts and to post a warning. To do so, follow these steps.
- Start Microsoft Access.
- On the Help menu, point to Sample Databases, and then click Northwind Sample Access Project.
- Minimize this instance of Access.
- Open a second instance of Access.
- Create a new project named Nwind2.adp connected to NorthwindCS.adp.
- Return to NorthwindCS.adp.
- Open the Categories form in Design view.
- On the View menu, click Code.
- Type or paste the following code:
Dim strTemp As String
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo MyForm_Err
Dim cnn As ADODB.Connection
Dim MyRS As New ADODB.Recordset
Dim strOld As String
Dim iAns As Integer
Set cnn = CurrentProject.Connection
MyRS.Open "select Categories.Description from Categories where CategoryID =" & Me.CategoryID, cnn, adOpenStatic
strOld = MyRS!Description
If Me.Description <> strTemp Then
iAns = MsgBox("The record was changed by another user. Current record is: " & vbCr & vbCr & strOld _
& vbCr & vbNewLine & "Your changes to record are: " & vbCr & vbCr & Me.Description & vbCrLf _
& vbNewLine & "Do you wish to overwrite the current Record with the changes you made?" _
& vbCr & "OK to keep your changes or Cancel to keep current record.", _
vbOKCancel, "Write Conflict")
If iAns = 2 Then
Me.Description = strOld
End If
End If
MyRS.Close
Set MyRS = Nothing
Set cnn = Nothing
MyForm_Exit:
Exit Sub
MyForm_Err:
Resume MyForm_Exit
End Sub
Private Sub Form_Current()
If IsNull(Me.Description) Then
Else
strTemp = Me.Description
End If
End Sub
- Save the form, and then view the form in Form view.
- Return to Nwind2.adp.
- Open the Categories table and edit the Description field in the first record. Change the record to "Soft drinks, coffees, teas, beers, and ales old."
- Move to the second record.
- Return to NorthwindCS.adp
- Edit the Description field in the first record. Change the record to "Soft drinks, coffees, teas, beers, and ales new."
- Move to the second record.
- Note that you receive the following message:
The record was changed by another user. Current record is:
Soft drinks, coffees, teas, beers, and ales old
Your changes to the record are:
Soft drinks, coffees, teas, beers, and ales new
Do you wish to overwrite the current Record with the changes you made?
OK to keep your changes or Cancel to keep current record.
- Click OK to keep your changes, or click Cancel to keep the current record.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
| Modification Type: | Major | Last Reviewed: | 9/26/2003 |
|---|
| Keywords: | kbbug KB295169 |
|---|
|