Results 1 to 4 of 4
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Answer a message box

    Hello,

    I'm almost finished with my latest database, thank you all for your help so far. Just one last issue that I know of.
    My form gathers a list of names and other information from the table of visitors that have not yet been approved. At the top of the form is a command button that allows the boss to approve all visitors at once. This simply writes to the table a value of -1 to a checkbox, and works great. Another checkbox on the form writes to the table to change a checkbox to -1 to make them exempt from some requirements, which also seems to be working fine.
    My problem comes in when I check the Exempt checkbox, then try to approve all visitors. Everything is writing fine like I want it to, but I get a messagebox that says...

    Write Conflict
    This record has been changed by another user since you started editing it. If you save the record, you will overwrite the changes the other user made.


    Copying the changes to the clipboard will let you look at the values the other user entered, and then paste your changes back if you decide to make changes.
    ...Then three buttons to choose from...
    Save Record Copy to Clipboard Drop Changes

    Copy to clipboard is the default.
    I looked this up, and it's saying something about making a change to a form when two forms with the same data source are open, but this is the only form that is opened when I'm testing it out. It also said to add code to the "On Deactivate" property
    DoCmd.RunCommand acCmdSaveRecord
    but it doesn't change anything.
    Another site said to change the Record Locks property to "Edited Record", but then I get a run-time error 3188-Could not update;Currently locked by another session on this machine.

    Can someone explain why this is happening? I make changes to forms all the time, and I've never seen this before. If I can't get the message to stop, is there a way to at least select the Copy to Clipboard default with code so the user doesn't even see what is happening?

  2. #2
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    I think I found the root of the problem that may explain what is going on, but I'm not sure how to fix it.
    When the form opens, the check box gets clicked, and this change is saved directly to the table.
    When the Exempt box is checked, the code on After Update is

    Private Sub chkXMT_AfterUpdate()
    'Makes visitor exempt if checked


    Dim rName As String
    Dim rXMT As Integer
    rName = Me.txtVName
    rXMT = Me.chkXMT

    CurrentDb.Execute "UPDATE tblVstr SET tblVstr.VstrXMT = " & rXMT & " WHERE " & _
    "[VstrName] = '" & rName & "'"

    End Sub


    The Approve All button has the following code

    Private Sub cmdAppAll_Click()
    'Checks all checkboxes on approval form

    Dim rs As DAO.Recordset
    Dim frm As String
    Set rs = CurrentDb.OpenRecordset("qryApprove")

    With rs
    .MoveFirst
    Do While Not rs.EOF
    .Edit
    !VisitApproved = -1
    .Update
    .MoveNext
    Loop
    End With


    rs.Close
    Set rs = Nothing


    DoCmd.Close

    End Sub

    Although there is only one form open, changes are attempting to be made on the form itself as well as with the code.
    It's getting late & my brain isn't working to normal capacity any more, so I'm hoping for some advice on the best way to go about this.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Using the acCmdSaveRecord before running code for programmatically updating records should work. Not seeing it in your posted code.

    An alternative uses the form IsDirty property. http://www.techrepublic.com/blog/mic...ss-using-code/

    Why don't you use an UPDATE sql action instead of looping recordset?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    I had the acCmdSaveRecord code in the On Deactivate property of the form. I went ahead & tried it out at the end of the chkXMT_AfterUpdate() code instead and it is working correctly, no more errors or message boxes. Thank you for probably the 100th time for your help. Also, as far as your last question, I usually plug in old code into new databases to try to accomplish the same type of outcome. I am not comfortable enough with code yet to know how to apply it to so many things, so I often run into problems that I don't know enough about to solve myself. You guys are the greatest!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Split Table - have been looking for answer
    By JoJo6205 in forum Access
    Replies: 7
    Last Post: 02-26-2015, 01:04 PM
  2. Answer abuot Combo Box
    By mojahed.mroteza in forum Access
    Replies: 5
    Last Post: 07-14-2012, 11:18 AM
  3. SBA IT national Elections answer
    By Paula in forum Import/Export Data
    Replies: 2
    Last Post: 10-22-2011, 07:29 AM
  4. There should be an easy answer, Please Help.
    By tucker1003 in forum Database Design
    Replies: 3
    Last Post: 03-03-2011, 01:03 PM
  5. Substitute Teacher in need of answer key!
    By misssunshine1973 in forum Access
    Replies: 4
    Last Post: 05-14-2009, 02:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums