473,734 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Taking control of a record

Hi All,
I have created a multi-user application at work which is working
perfectly apart from a small problem which I believe to more a of a user
issue (maybe some will set me straight on that one). I have set the 'Default
Record Locking' option to 'Edited Record' in the hope that if someone tries
to edit a record someone has open, they would not be able to do so.

After a little testing, I found this not to be the case. Instead, if 2 users
are editing a record at the same time and one of them moves to another
record, the user moving to a new record is presented with a 'Write Conflict'
message giving them 3 options of:
* Save Record
* Copy to clipboard
* Drop changes

I wish to eliminate this happening by making the user "Take Control" of the
record before they can begin to edit it.

I have started this process by adding a text field to the underlying table
called 'LockedBy'. I have also set the AllowEdits option of the form to
False.

To edit the record, the user must first click a command button which checks
if the LockedBy field is Null. If it is, it updates the field with their
UserID (I have a custom login form combined with Access built in security)
and sets the AllowEdits option to True.

Now, should another user try to take control of the record, a check is
performed to see if the field is null (combined with a check to see if the
LockedBy field matches the current user), if it isn't, they receive a
message box stating that they cannot edit the record until xxxxxxx releases
control of it.

This works perfectly except for one problem. Once the user that has control
of the record is finished with it, I need to make sure they release control.
This is what I can't figure out how to do.

I am not a programmer and have only recently started to dabble. Below is the
code I am using. If anyone has any better suggestions on how to achieve the
same result, I'd be very grateful.

TIA,

Mark

Private Sub cmd_TakeControl _Click()

'If the record is locked by someone other than current user,
If Me.Locked.Value = True And Me.LockedBY.Val ue <>
Displayname(For ms!frm_userlogi n!txt_UserID) Then
MsgBox "This record is currently locked by " & Me.LockedBY.Val ue &
vbCrLf & _
"You cannot edit this record until they release control of it",
vbInformation, "Record Locked"
Me.cmd_TakeCont rol.Caption = "Take Control"
Me.AllowEdits = False

'If the record is lockedby the current user, determine the command caption
ElseIf Me.Locked.Value = True And Me.LockedBY.Val ue =
Displayname(For ms!frm_userlogi n!txt_UserID) Then
'the current user has the record locked, determine if they clicked to
release or take control
If Me.cmd_TakeCont rol.Caption = "Take Control" Then
Me.AllowEdits = True
Me.Locked = True
Me.LockedBY.Val ue = Displayname(For ms!frm_userlogi n!txt_UserID)
Me.cmd_TakeCont rol.Caption = "Release Control"
Else
Me.AllowEdits = False
Me.Locked = False
Me.LockedBY.Val ue = Null
Me.cmd_TakeCont rol.Caption = "Take Control"
End If

Else 'No-one has control of the record

Me.AllowEdits = True
Me.Locked = True
Me.LockedBY.Val ue = Displayname(For ms!frm_userlogi n!txt_UserID)
If Me.Dirty = True Then
Me.Dirty = False
End If

Me.cmd_TakeCont rol.Caption = "Release Control"
End If
End Sub
May 23 '06 #1
2 2441
Good news and bad news, I think.

Good: Use the form's afterupdate event to clear whatever you set up in the
takecontrol code.

Bad: Your problem may be due to the fact that in Access (actually in the Jet
Engein) record locking is not exactly record locking. Up through Access
2000 what is called "record locking" was actuall "page locking". All the
records on a single page were locked, rather than being able to truly lock a
single record, as you can in SQL Server/Oracle/etc. I don't find any
information that says this has changed in later editions.

---------------------------------------------------------------------------------------------

Our solution was to move to unbound forms, which meant using a function to
create a recordset, load the data into the unbound controls on a form, then
close the recordset. A Save button fires the inverse function to write data
out of the controls back into a writeable recordset created only for the
instant it takes to write the data.

The whole library of routines was less than 400 lines of code, including
logging changes to our own table of changes to keep track of who changed
what field from what to what when.

May 23 '06 #2
Hi again,
I thought I would post the solution I have come up with which may be
ugly but it works.....

I created an unbound text box and check box on the form footer which are
both set to Visible = False.
When the user takes control of a record, the check box value is updated to
True and the text box value is updated to the records ID.
Using the OnCurrent event of the form, I have a check to see if the value of
the check box is True. If it is, the current Record ID is compared with the
value of the unbound textbox. If they differ, the user is alerted that they
have left a record locked and an ApplyFilter command is run using the
unbound textbox value as the criteria.

I also have the same checks in the form's Unload event should they just
close the form after an edit.

As I said, it may be ugly but it works!!!!

Many thanks,

Mark
"Mark Reed" <ma*********@nt lworld.com> wrote in message
news:he******** *****@newsfe2-win.ntli.net...
Hi All,
I have created a multi-user application at work which is working
perfectly apart from a small problem which I believe to more a of a user
issue (maybe some will set me straight on that one). I have set the 'Default
Record Locking' option to 'Edited Record' in the hope that if someone tries
to edit a record someone has open, they would not be able to do so.

After a little testing, I found this not to be the case. Instead, if 2 users
are editing a record at the same time and one of them moves to another
record, the user moving to a new record is presented with a 'Write Conflict'
message giving them 3 options of:
* Save Record
* Copy to clipboard
* Drop changes

I wish to eliminate this happening by making the user "Take Control" of the
record before they can begin to edit it.

I have started this process by adding a text field to the underlying table
called 'LockedBy'. I have also set the AllowEdits option of the form to
False.

To edit the record, the user must first click a command button which checks
if the LockedBy field is Null. If it is, it updates the field with their
UserID (I have a custom login form combined with Access built in security)
and sets the AllowEdits option to True.

Now, should another user try to take control of the record, a check is
performed to see if the field is null (combined with a check to see if the
LockedBy field matches the current user), if it isn't, they receive a
message box stating that they cannot edit the record until xxxxxxx releases
control of it.

This works perfectly except for one problem. Once the user that has control
of the record is finished with it, I need to make sure they release control.
This is what I can't figure out how to do.

I am not a programmer and have only recently started to dabble. Below is the
code I am using. If anyone has any better suggestions on how to achieve the
same result, I'd be very grateful.

TIA,

Mark

Private Sub cmd_TakeControl _Click()

'If the record is locked by someone other than current user,
If Me.Locked.Value = True And Me.LockedBY.Val ue <>
Displayname(For ms!frm_userlogi n!txt_UserID) Then
MsgBox "This record is currently locked by " & Me.LockedBY.Val ue &
vbCrLf & _
"You cannot edit this record until they release control of it",
vbInformation, "Record Locked"
Me.cmd_TakeCont rol.Caption = "Take Control"
Me.AllowEdits = False

'If the record is lockedby the current user, determine the command caption
ElseIf Me.Locked.Value = True And Me.LockedBY.Val ue =
Displayname(For ms!frm_userlogi n!txt_UserID) Then
'the current user has the record locked, determine if they clicked to
release or take control
If Me.cmd_TakeCont rol.Caption = "Take Control" Then
Me.AllowEdits = True
Me.Locked = True
Me.LockedBY.Val ue = Displayname(For ms!frm_userlogi n!txt_UserID)
Me.cmd_TakeCont rol.Caption = "Release Control"
Else
Me.AllowEdits = False
Me.Locked = False
Me.LockedBY.Val ue = Null
Me.cmd_TakeCont rol.Caption = "Take Control"
End If

Else 'No-one has control of the record

Me.AllowEdits = True
Me.Locked = True
Me.LockedBY.Val ue = Displayname(For ms!frm_userlogi n!txt_UserID)
If Me.Dirty = True Then
Me.Dirty = False
End If

Me.cmd_TakeCont rol.Caption = "Release Control"
End If
End Sub

May 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
1852
by: Ideasman | last post by:
Hi I have a made a script that process normals for a flat shaded 3D mesh's. It compares every vert with every other vert to look for verts that can share normals and It takes ages. I'm not asking anyone to rewrite the script- just have a look for any stupid errors that might be sucking up time.
6
3416
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get sized strangely using the .RTFHeight property of the control. Specifically, lines of text get cut off the bottom of the control when I use the code provided in the sample report on the lebans.com site. It seems that when there is Chinese text,...
2
3748
by: John Hargrove | last post by:
I'm having trouble setting decimal place values in the results field of a sample management database I'm building for an environmental testing laboratory. The degree of sensitivity varies among test methods; consequently, some results are reported to 2 decimal places, some to 3, etc. The Results subform consists of Test Parameter, Result, Report Unit, Analysis Date, Analyst and other fields. The test parameter control is a drop-down...
7
2055
by: vindaloo1 | last post by:
I'm using Access 2000 and I have a main form and a subform. When a control on the subform is updated I am trying to update a control on the mainform. But instead of updating the control on the main form's current record, it updates the main form's control on every record. This is the code I'm using for this: Set cnn = CurrentProject.Connection strSQL = "SELECT SUM(AmountPaid)AS SumAmountPaid FROM BillPayments WHERE " & _
2
1611
by: MLH | last post by:
I have a form based on a table. The table has a Yes/No field. Its an A97 table. The form has a button that updates the value in the control from No to Yes for the record currently being edited. It seems the ONLY way I can make the control reflect the Yes value is to save the record. Not that its too much trouble to save it, but there are other fields whose values are going to be modifed during the instance of the current record and I...
2
1132
by: JJ | last post by:
OK - I asked this earlier but thought I'd solved it. Clearly not. I have a control that I need to display text from an sql database. The control is being used as a web part so can be placed on a page more than once. I am trying to work out how I'd get each instance of the control to load its corresponding database record to display the text? I would normally do this sort of thing via a querystring, but in this case
7
1887
by: Computer Guru | last post by:
Hi, Pardon the unclear/verbose subject, I just can't think of another way of phrasing it. Basically, I can assign the (for instance) "Location" property of a picture box to a data-bound item. Like, I can get the absoloute location from an ADO.NET database, and assign it to the PictureBox.Location property.
2
2770
by: angi35 | last post by:
I hope this is an easy question for someone out there. In Access 2000…I have a MainForm with a tab control (MAIN TABS) with 7 tabs. Within each tab is a SubForm. Within each SubForm is a tab control (TabCtl0) with 2-6 tabs. Within each TabCtl0, each tab contains a SubSubForm. Each record in the MainForm has an ID Number; the SubForms are bound to that ID Number, and the SubSubForms are bound to that ID Number in the SubForms. In order...
6
1901
by: Gouri.Mahajan7 | last post by:
Hello, When I press the button on the web page I am loading the user control on the web page. This user control is invoking some methods of the web service. The control on the web page is loaded very soon when running on the local machine ( measns where the web service is running). But it is taking lot of time when loaded on the remote machine. Can anybody please explain me how to solve this problem?
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.