Locked Record Indicator

  • Thread starter Thread starter DebbieG
  • Start date Start date
D

DebbieG

I have created a database for a client and was told that it was to be a
one-user database. Well, you know the next statement ... now they want 3
people to be able to use the database. (FYI, I have never created a
database for multiusers. I've done some searching but not finding what I
want.)

I have split the database. In Tools, Options, I have set the following:

Default open mode = Shared
Default record locking = Edited Record
Checked Open databases using record-level locking

And this is some of the code behind one of my forms:

Private Sub Form_Open(Cancel As Integer)
If Me.RecordLocks <> 2 Then
Me.RecordLocks = 2 'lock at the record level
End If
End Sub

Private Sub Form_Dirty(Cancel As Integer)
Me.cmdSave.Visible = True
Me.cmdUndo.Visible = True
Me.cmdAdd.Visible = False
Me.ComboStudent.Enabled = False
Me.cmdDelete.Visible = False
End Sub

I reset the above in Form_Current.

In testing to see how my form will react, I opened the database twice and
tried to edit the same record. I get the Locked Record Indicator but
Form_Dirty is activated if they attempt to make a change, so the Save and
Undo buttons appear, but the user can't change anything.

Is there a way to capture the Locked Record Indicator? Or what can I do so
the Form_Dirty doesn't activate? I thought it would be a nice feature to
use a msgbox to tell the 2nd user that someone else is editing the same
record.

I will have a lot of forms to change so the easiest way I can do this the
better.

Thanks in advance for any suggestions/help,
Debbie
 
I found an answer to my problem:

Private Sub Form_Dirty(Cancel As Integer)
If Me.Dirty then
Me.cmdSave.Visible = True
Me.cmdUndo.Visible = True
Me.cmdAdd.Visible = False
Me.ComboStudent.Enabled = False
Me.cmdDelete.Visible = False
End If
End Sub

At least that keeps the Dirty event from firing so the user doesn't think
they can edit. Thanks to Tom on comp.databases.ms-access.

Hope that helps someone else.

Debbie


I have created a database for a client and was told that it was to be a
one-user database. Well, you know the next statement ... now they want 3
people to be able to use the database. (FYI, I have never created a
database for multiusers. I've done some searching but not finding what I
want.)

I have split the database. In Tools, Options, I have set the following:

Default open mode = Shared
Default record locking = Edited Record
Checked Open databases using record-level locking

And this is some of the code behind one of my forms:

Private Sub Form_Open(Cancel As Integer)
If Me.RecordLocks <> 2 Then
Me.RecordLocks = 2 'lock at the record level
End If
End Sub

Private Sub Form_Dirty(Cancel As Integer)
Me.cmdSave.Visible = True
Me.cmdUndo.Visible = True
Me.cmdAdd.Visible = False
Me.ComboStudent.Enabled = False
Me.cmdDelete.Visible = False
End Sub

I reset the above in Form_Current.

In testing to see how my form will react, I opened the database twice and
tried to edit the same record. I get the Locked Record Indicator but
Form_Dirty is activated if they attempt to make a change, so the Save and
Undo buttons appear, but the user can't change anything.

Is there a way to capture the Locked Record Indicator? Or what can I do so
the Form_Dirty doesn't activate? I thought it would be a nice feature to
use a msgbox to tell the 2nd user that someone else is editing the same
record.

I will have a lot of forms to change so the easiest way I can do this the
better.

Thanks in advance for any suggestions/help,
Debbie
 
I celebrated a little too soon. This works on the 2nd user but now it
doesn't fire on the 1st user. I tried moving this code to OnCurrent but
that didn't work either. Anybody out there with any ideas?

Debbie


I found an answer to my problem:

Private Sub Form_Dirty(Cancel As Integer)
If Me.Dirty then
Me.cmdSave.Visible = True
Me.cmdUndo.Visible = True
Me.cmdAdd.Visible = False
Me.ComboStudent.Enabled = False
Me.cmdDelete.Visible = False
End If
End Sub

At least that keeps the Dirty event from firing so the user doesn't think
they can edit. Thanks to Tom on comp.databases.ms-access.

Hope that helps someone else.

Debbie


I have created a database for a client and was told that it was to be a
one-user database. Well, you know the next statement ... now they want 3
people to be able to use the database. (FYI, I have never created a
database for multiusers. I've done some searching but not finding what I
want.)

I have split the database. In Tools, Options, I have set the following:

Default open mode = Shared
Default record locking = Edited Record
Checked Open databases using record-level locking

And this is some of the code behind one of my forms:

Private Sub Form_Open(Cancel As Integer)
If Me.RecordLocks <> 2 Then
Me.RecordLocks = 2 'lock at the record level
End If
End Sub

Private Sub Form_Dirty(Cancel As Integer)
Me.cmdSave.Visible = True
Me.cmdUndo.Visible = True
Me.cmdAdd.Visible = False
Me.ComboStudent.Enabled = False
Me.cmdDelete.Visible = False
End Sub

I reset the above in Form_Current.

In testing to see how my form will react, I opened the database twice and
tried to edit the same record. I get the Locked Record Indicator but
Form_Dirty is activated if they attempt to make a change, so the Save and
Undo buttons appear, but the user can't change anything.

Is there a way to capture the Locked Record Indicator? Or what can I do so
the Form_Dirty doesn't activate? I thought it would be a nice feature to
use a msgbox to tell the 2nd user that someone else is editing the same
record.

I will have a lot of forms to change so the easiest way I can do this the
better.

Thanks in advance for any suggestions/help,
Debbie
 
I finally found what I needed. I found it on the Microsoft Knowledge Base
(article 122294 - How to automatically detect if a form is being edited).
There were two methods suggested and I chose to use the Dirty Property in an
Expression. In summary, here's what worked:



I created the following function in the module:



Function EditModeChange (F as Form) as Variant

If F.Dirty then

F!cmdSave.Visible = True

F!cmdUndo.Visible = True

F!cmdAdd.Visible = False

F!ComboStudent.Enabled = False

F!cmdDelete.Visible = False

else

F!cmdSave.Visible = False

F!cmdUndo.Visible = False

F!cmdAdd.Visible = True

F!ComboStudent.Enabled = True

F!cmdDelete.Visible = True

End If

End Function



I added a new textbox to my form:



Name: txtEditModeChange

Control Source: =[Form].[Dirty] & EditModeChange([Form])

Visible: No



In Form_AfterUpdate:



Sub Form_AfterUpdate()

Me!txtEditModeChange.Requery

End Sub



Now, if a second user tries to edit the same record as someone else the Save
and Undo buttons don't appear.



Hope this helps someone else.



Debbie



I have created a database for a client and was told that it was to be a
one-user database. Well, you know the next statement ... now they want 3
people to be able to use the database. (FYI, I have never created a
database for multiusers. I've done some searching but not finding what I
want.)

I have split the database. In Tools, Options, I have set the following:

Default open mode = Shared
Default record locking = Edited Record
Checked Open databases using record-level locking

And this is some of the code behind one of my forms:

Private Sub Form_Open(Cancel As Integer)
If Me.RecordLocks <> 2 Then
Me.RecordLocks = 2 'lock at the record level
End If
End Sub

Private Sub Form_Dirty(Cancel As Integer)
Me.cmdSave.Visible = True
Me.cmdUndo.Visible = True
Me.cmdAdd.Visible = False
Me.ComboStudent.Enabled = False
Me.cmdDelete.Visible = False
End Sub

I reset the above in Form_Current.

In testing to see how my form will react, I opened the database twice and
tried to edit the same record. I get the Locked Record Indicator but
Form_Dirty is activated if they attempt to make a change, so the Save and
Undo buttons appear, but the user can't change anything.

Is there a way to capture the Locked Record Indicator? Or what can I do so
the Form_Dirty doesn't activate? I thought it would be a nice feature to
use a msgbox to tell the 2nd user that someone else is editing the same
record.

I will have a lot of forms to change so the easiest way I can do this the
better.

Thanks in advance for any suggestions/help,
Debbie
 
Back
Top