D
DebbieG
I am really struggling.
I put the following code in a form:
Default Open Mode = Shared
Default Record Locking = Edited Record
Open databases using record-level locking is checked
Form, Record Locks = Edited Record
Default View = Single Form
Property Get RowLocked() As Boolean
Dim rs As DAO.Recordset
Set rs = Me.Recordset
On Error Resume Next
rs.Edit
RowLocked = (Err.Number = 3260) 'record locked
rs.CancelUpdate
End Property
Private Sub Form_Current()
On Error GoTo GotError
If Me.RowLocked Then
Me.lblEditModeChange.Visible = True
Else
Me.lblEditModeChange.Visible = False
End If
Me.Refresh
If Me.NewRecord Then
Me.txtRecordCount.Caption = "New Record"
Else
With Me.RecordsetClone
.MoveLast
.Bookmark = Me.Bookmark
Me.txtRecordCount.Caption = "Record " & Me.CurrentRecord & "
of " & .RecordCount
End With
Me.AllowAdditions = False
End If
ExitSub:
Exit Sub
GotError:
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "Form_Current"
Resume ExitSub
End Sub
The weird thing is that this code works fine on a another form. If I open
the database, open this form, edit a record, open another instance of the
database, open this form, ALL RECORDS ARE LOCKED. I opened the table that
this form is based on and the first record is shown as locked and that's not
the one I'm editing. I have looked and looked but I can't find any
differences in way these two forms are set up. The only difference between
the two forms is that one that works has a drop-down box at the top to look
up records, this form doesn't. Why should that make a difference?
I'm going to have some continuous forms that I will want to put some similar
coding in and they won't have a drop-down lookup box. I'm assuming I'll
have the same problems. What am I missing?
I've learned so much from this group ... in fact I found this code here.
Thanks in advance for any help and/or suggestions.
Debbie
I put the following code in a form:
Default Open Mode = Shared
Default Record Locking = Edited Record
Open databases using record-level locking is checked
Form, Record Locks = Edited Record
Default View = Single Form
Property Get RowLocked() As Boolean
Dim rs As DAO.Recordset
Set rs = Me.Recordset
On Error Resume Next
rs.Edit
RowLocked = (Err.Number = 3260) 'record locked
rs.CancelUpdate
End Property
Private Sub Form_Current()
On Error GoTo GotError
If Me.RowLocked Then
Me.lblEditModeChange.Visible = True
Else
Me.lblEditModeChange.Visible = False
End If
Me.Refresh
If Me.NewRecord Then
Me.txtRecordCount.Caption = "New Record"
Else
With Me.RecordsetClone
.MoveLast
.Bookmark = Me.Bookmark
Me.txtRecordCount.Caption = "Record " & Me.CurrentRecord & "
of " & .RecordCount
End With
Me.AllowAdditions = False
End If
ExitSub:
Exit Sub
GotError:
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "Form_Current"
Resume ExitSub
End Sub
The weird thing is that this code works fine on a another form. If I open
the database, open this form, edit a record, open another instance of the
database, open this form, ALL RECORDS ARE LOCKED. I opened the table that
this form is based on and the first record is shown as locked and that's not
the one I'm editing. I have looked and looked but I can't find any
differences in way these two forms are set up. The only difference between
the two forms is that one that works has a drop-down box at the top to look
up records, this form doesn't. Why should that make a difference?
I'm going to have some continuous forms that I will want to put some similar
coding in and they won't have a drop-down lookup box. I'm assuming I'll
have the same problems. What am I missing?
I've learned so much from this group ... in fact I found this code here.
Thanks in advance for any help and/or suggestions.
Debbie