Record Lock Problem

Posted on 2005-04-23
Last Modified: 2010-08-05
Hi Experts:

I'm using the following code which works okay except that after you access a record once and quit, then access that same record again, it's locked like it is suppose to be, however, if you click the save button you get a message box that says the save command is not available, however, you can then edit the record, in other words, it is no longer locked.

If this doesn't make sense let me know and I'll provide more detail.

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Me![Locked] = True

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunCommand acCmdDataEntry
    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command6_Click

End Sub

Private Sub Form_Current()

If IsNull(Me![Locked]) Then Me![Locked] = 0
Me.AllowEdits = Not Me![Locked]

End Sub

Private Sub form_open(Cancel As Integer)
    If Me.RecordsetClone.RecordCount = 0 Then
        DoCmd.OpenForm "Form3"
        Cancel = True
    End If
End Sub


Question by:whitesandsbeach
    1 Comment
    LVL 17

    Accepted Solution

    When you add a boolean field to a table, it is always a good idea to do and update query and set the value of the field to something other than Null.  That way you won't have any indeterminate states to test for.  Maybe just simplifying this:

    Private Sub Form_Current()

    If Me![Locked]
       Me.AllowEdits = Me![Locked]
       Me.AllowEdits = Not Me![Locked]
    End Sub

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now