Advertisement

08.28.2008 at 08:08AM PDT, ID: 23685795
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Write Conflict Error

Asked by jondecker76 in Access Coding/Macros, SQL Query Syntax, Access Architecture/Design

Tags: , ,

I am getting a write conflict error on one of my forms. I think I know the reason why, I just don't know how to fix it.

On my main form, I do a "Select * FROM TableName" query...
There is a checkbox on my form. It is unbound, but looks at a text field in the table. I use the text field for permissions. The checkbox is used to "lock" a textfield from edition. What happens is, on the form, the user checks the checkbox to lock the textfield. Then, in VBA code, i execute an Update query which updates a text field with the username environmental variable. This way, the user that locked the text field is the only user that can unlock it. All other users get a message when trying to unlock it, alerting them that username has it locked, and to contact them. This is managed by checking for the existance of a username in the table's text field. If one is set, then the checkbox is checked and the textbox.Locked is set to true.
In the AfterUpdate of the checkbox, here is the code:
Private Sub chkDescriptionLock_AfterUpdate()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim lockingUser As String
   
    'Get connection to database
    Set dbs = CurrentDb()
   
    If Me.chkDescriptionLock Then
        'Box is checked
        txtPartitionDescription.Locked = True
       
        'Build SQL query
        strSQL = "UPDATE Partition Set Partition.Description_LockedBy = '" & GetUserName() & "' where Partition.Pk_Partition = " & [PK_Partition] & ";"
        dbs.Execute (strSQL)
       
        MsgBox "You have now locked the description from editing. Only you can now remove the lock"
       

    Else
        'Box is Unchecked
       
        strSQL = "SELECT Partition.Description_LockedBy from Partition WHERE Partition.PK_Partition = " & [PK_Partition] & ";"
        Set rst = dbs.OpenRecordset(strSQL)
       
        lockingUser = rst.Fields("Description_LockedBy")
       
        If lockingUser = GetUserName() Then
            'Build SQL query
            strSQL = "UPDATE Partition Set Partition.Description_LockedBy = '' where Partition.Pk_Partition = " & [PK_Partition] & ";"
            dbs.Execute (strSQL)
            txtPartitionDescription.Locked = False
       
            MsgBox "Description field successfully unlocked!"
        Else
            Me.chkDescriptionLock.value = 1
            MsgBox "Description field is locked by " & lockingUser & "." & vbCrLf & "You will need to contact this user to unlock it"
        End If
    End If
End Sub

As you can see, its pretty straight forward.

I think I'm getting the Write Conflict Error because I am using an Update query in VBA to change the value in the database, while form never gets updated to reflect this. How do a pull in the new changes into my form, and do so without screwing up how my form is filtered? (see how it is filtered below:)
Private Sub SyncFormToCombobox()
    '--------------------------------------
    'SyncFormToListbox()
    'This function syncronizes the forms
    'recordset to the the listbox browser
    '---------------------------------------
   
    'lets syncronize the form's recordset
    Set rs = Me.RecordsetClone
    rs.FindFirst "[PK_Partition] =" & Str(Nz(Me![cmbBrowse], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    DescriptionLock

End Sub



thanks for any help I can get...Start Free Trial
[+][-]08.28.2008 at 12:29PM PDT, ID: 22338814

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, SQL Query Syntax, Access Architecture/Design
Tags: Microsoft, Access, 2003
Sign Up Now!
Solution Provided By: LennyGray
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628