All records are locked

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
 
D

DebbieG

I forgot to tell you that I'm using Access XP and Default File Format is
Access 2000.
Debbie

|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
|
|
 
D

DebbieG

OK, I checked a little and it's not locking all records, just 14-15
surrounding the edited record. Why would it do this if I selected to lock
on the edited record?

Debbie

|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
|
|
 
M

Michael Cheng [MSFT]

Hi DebbieG,

Thanks for your posting!

From your descriptions, I understood that you records will be locked when
the database was open in second form. Have I understood you? However, I am
not sure whether it will still locked when only one Form was open? Any
error messages when the records was locked?

To understand better, is it possible for you to generate that two small
sample for me, with which I will be able to reproduce it on my side (you
could using Northwind database on local SQL Server instead )? My email is
(e-mail address removed) (please remove "online" as it's only for SPAM)

Thank you for your patience and corporation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!


Sincerely yours,

Michael Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
 
D

DebbieG

I tweaked my code a little:


Property Get RowLocked() As Boolean
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.Bookmark = Me.Bookmark
On Error Resume Next
rs.Edit
RowLocked = (Err.Number <> 0)
rs.CancelUpdate
End Property

I also set Subdatasheet in Table Properties to None.

I don't know if it was the changes I made in the Property Get RowLocked or
the changes I made to the tables properties, but only one record is locked
now.

Debbie


|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
|
|
 
M

Michael Cheng [MSFT]

Hi DebbieG,

What's in the drop down list? Is it the same table as the edited table? The
row source of the combo/list boxes will be locked when it is running,

Sincerely yours,

Michael Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
 
D

DebbieG

The drop-down list is based on a query that's based on the same table as the
form.
I never thought to test the drop-down list.

Debbie


| Hi DebbieG,
|
| What's in the drop down list? Is it the same table as the edited table?
The
| row source of the combo/list boxes will be locked when it is running,
|
| Sincerely yours,
|
| Michael Cheng
|
| Online Partner Support Specialist
| Partner Support Group
| Microsoft Global Technical Support Center
| ---------------------------------------------------------------
| Get Secure! - http://www.microsoft.com/security
|
| This posting is provided "as is" with no warranties and confers no rights.
| Please reply to newsgroups only, many thanks!
|
 
M

Michael Cheng [MSFT]

Hi Debbie,

How are things going? I would appreciate it if you could post here to let
me know the status of the issue. If you have any questions or concerns,
please don't hesitate to let me know. I look forward to hearing from you,
and I am happy to be of assistance.


Sincerely yours,

Michael Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
 
M

Michael Cheng [MSFT]

Hi Tanya,

I would love to help, however, would you please let me know what do you
mean by "live tech" ?


Sincerely yours,

Michael Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top