Jim Dettman
jimdettman at verizon.net
Mon Jan 14 13:03:12 CST 2008
John, That's it other then try to read the locks JET places. Trying an edit though is simple. See below. BTW this is very old code. Might need some rework. Jim. Function IsLocked(rs As Recordset, UserName As String, MachineName As String) ' Accepts: a recordset and two string variables ' Purpose: determines if the current record in the recordset is locked, ' and if so who has it locked. ' Returns: True if current record is locked (and sets UserName ' and MachineName to the user with the lock). False if the ' record isn't locked. ' From: Building Applications Chapter 12 Dim ErrorString As String Dim MachineNameStart As Integer IsLocked = False On Error GoTo IsLockedError rs.Edit 'Try to edit the current record in the recordset. rs.MoveNext rs.MovePrevious Exit Function 'No error, so return False. IsLockedError: If Err = 3260 Then 'Record is locked -- parse error string. ErrorString = Error$ UserName = Mid$(ErrorString, 44, InStr(44, ErrorString, "'") - 44) If UserName = "" Then UserName = "(unknown)" MachineNameStart = InStr(43, ErrorString, " on machine ") + 13 MachineName = Mid$(ErrorString, MachineNameStart, Len(ErrorString) - MachineNameStart - 1) If MachineName = "" Then MachineName = "(unknown)" IsLocked = True End If Exit Function End Function ' -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Monday, January 14, 2008 12:31 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Determine if a record is locked? Is there any way to programmatically determine whether a record is locked other than try a write and see if it errors? John W. Colby Colby Consulting www.ColbyConsulting.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com