Record Lock Problem

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_Command6_Click:
    Exit Sub

Err_Command6_Click:
    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

Thanks,

whitesandsbeach
whitesandsbeachAsked:
Who is Participating?
 
ArjiCommented:
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]
Else
   Me.AllowEdits = Not Me![Locked]
End Sub
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.