UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Lock Row Of Subform, Access 2003    
 
   
ayen
post Oct 27 2014, 04:41 AM
Post#1



Posts: 937
Joined: 9-May 13



Hello UA,
I have a situation that far beyond my knowledge..
I have a MainForm - subForm situation. subform row to lock if record is not mine.. but editable if mine..
The purpose of the subform is to log note/comment of the file (file tracking movement), from one department to another..
What I wanted to do is, lock the row/record being not to be edited by the person other than the note/comment he/she added him/her self.
I don't want that other department can change my note/comment. They should change/edit only what they enter.
I don't know how to achieve this, can someone please help me.
Appreciate any help please.
Thank you,
ayen
Go to the top of the page
 
Larry Larsen
post Oct 27 2014, 05:44 AM
Post#2


UA Editor + Utterly Certified
Posts: 24,361
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Hi ayen
A couple of things we need to know..
1) what format is the subform in: Single/Continuous.??
2) what makes the record unique to you..??
thumbup.gif
Go to the top of the page
 
ayen
post Oct 27 2014, 05:58 AM
Post#3



Posts: 937
Joined: 9-May 13



Hi Larry,
Thank you for picking me up.
Unfortunately, non of the view/format mention, it is a "datasheet".
The unique field/control is the PolicyNumber (being used as the link field). But as for the uniqueness of the note/comment per department is none (see attached)..
Hope that helps,
ayen
Attached File(s)
Attached File  Form_Subform.jpg ( 139.23K )Number of downloads: 8
 
Go to the top of the page
 
jleach
post Oct 27 2014, 06:35 AM
Post#4


UtterAccess Editor
Posts: 10,142
Joined: 7-December 09
From: St Augustine, FL


If you're tracking who entered previous records, and you're tracking who the active user is, you can compare the two in the Current event and set the AllowEdits property of the form accordingly:
CODE
If Me.EnteredBy = Me.ActiveUser Then
Me.AllowEdits = True
Else
  Me.AllowEdits = False
End If

If you're not tracking the user info in some way, it'll be a bit more difficult, and even then I think you'll only find half a solution looking at it without user tracking.
hth
Go to the top of the page
 
ayen
post Oct 27 2014, 06:46 AM
Post#5



Posts: 937
Joined: 9-May 13



Hello Jack,
How could I check the active user? If am going to go with your suggestion, should I add new field/control "enteredby" in the table/subform?
Can you please give more lights on how to check the active user please.
Thank you,
ayen
Go to the top of the page
 
jleach
post Oct 27 2014, 07:47 AM
Post#6


UtterAccess Editor
Posts: 10,142
Joined: 7-December 09
From: St Augustine, FL


Well, it's functionality that you'd have to build in yourself really... a login page, storing the active user somewhere after they're logged in (a hidden form's control is a common choice).
1) create a login form
2) after login, store the user somewhere
3) when new records are added, use BeforeUpdate to populate an "EnteredBy" (or similar) field
4) then you can implement user-based logic such as what you require
There's a bit to it, but it's a fairly common requirement that could be reused in many places.
The bottom line though, is that you need some way to programmatically determine what "mine" is. That could be a user, could be a computername, could be just the active session (when Access starts until it stops), but the later two have several disadvantages over a user login system.
There's lots of different ways to implement this... here's one of many http://www.UtterAccess.com/wiki/index.php/Login_Security
hth
Go to the top of the page
 
ayen
post Oct 27 2014, 08:04 AM
Post#7



Posts: 937
Joined: 9-May 13



Hi,
Is that complicated.... cryhard.gif
Well, I will try to go deeper, let's see what I can accomplish.
Thank you,
ayen
Go to the top of the page
 
iliyanuhu
post Oct 27 2014, 08:48 AM
Post#8



Posts: 122
Joined: 14-June 11



Hi Jack,
I used to add the userID into a TempVars() at login, and refer to it for comparisons of such kind, would you mind to point out on the disadvantages of such approach.
Regards.
Go to the top of the page
 
jleach
post Oct 27 2014, 10:37 AM
Post#9


UtterAccess Editor
Posts: 10,142
Joined: 7-December 09
From: St Augustine, FL


I don't really see any disadvantages to it... personally, I don't use TempVars but it's a viable means of handling it for sure. But, come to think of it, TempVars was introduced in 2007, and OP is looking for a 2003 solution, so that'd be out of the question anyway.
I had mentioned a hidden form because that's an approach many people take (I prefer a public property approach myself), but regardless of how it's stored, it still needs to be captured at login smile.gif Of course, that could be as easy as using fGetOSUserName (per MVPs.org/access), but that ties the username to the windows login, which may or may not be desirable.
Cheers,
Go to the top of the page
 
iliyanuhu
post Oct 27 2014, 05:30 PM
Post#10



Posts: 122
Joined: 14-June 11



Hi Jack,
i have similar situation with the OP if not for the version.
i am not familiar with the concept of Property, but i already have a hiden form that prevent my application form closing accidentally, so i assume, going by the idea of a hidden form, i would have to add a textBox to the form and assign the userID to it after login, and then keep refering to it for comparison later. is it?
Go to the top of the page
 
jleach
post Oct 27 2014, 06:23 PM
Post#11


UtterAccess Editor
Posts: 10,142
Joined: 7-December 09
From: St Augustine, FL


Yep, that's how it works. A property is basically just a fancy Global variable in a standard code module but many are more comfortable the hidden form/control. TempVars is perfectly find as well.
Go to the top of the page
 
ayen
post Oct 28 2014, 12:53 AM
Post#12



Posts: 937
Joined: 9-May 13



Hello Jack,
Good day (it is 8:47AM here in KSA),
Just a follow up, assuming that I have the log-in form and the hidden form to hold the activeuser/username.
How would it be the setup, taking the account that it will be on the subform to do the record locking (row).
Appreciate your help and please bear with me as I am learning specially on the "coding".
Thank you,
ayen
Go to the top of the page
 
iliyanuhu
post Oct 28 2014, 01:19 AM
Post#13



Posts: 122
Joined: 14-June 11



Hi,
i am sorry for squating with the OP on this post, but may be because we have somehow similar situation, i would like to ask, you Jack/someone else, for more on the declaration, setting and refering to the Property.
Regards.
Go to the top of the page
 
ayen
post Oct 28 2014, 02:14 AM
Post#14



Posts: 937
Joined: 9-May 13



Hi Iliya,
It's Ok... actually it benefitted me, coz you asked question that beyond my knowledge..
Can you please share how you setup your subform to check the activeuser and locked the rows which record is not belong to him/her (not equal to activeuser).
Many thanks,
ayen
Go to the top of the page
 
ayen
post Oct 28 2014, 02:31 AM
Post#15



Posts: 937
Joined: 9-May 13



Hello Jack, Iliya
Yes... yayhandclap.gif I did it... i did it..
Thank you very much Jack.. I love UA..
I created the login form as per your link to the wiki page.
I captured the ActiveUser from the login form
I put the code on the OnCurrent event of the subform
My best regards,
ayen
Go to the top of the page
 
iliyanuhu
post Oct 28 2014, 03:02 AM
Post#16



Posts: 122
Joined: 14-June 11



Hi Ayen,
I am sorry, but my system is only concerned about the best way to hold the current userID somewhere in the database, and for now am using TempVars.
I am glad you made it.
Regards.
Go to the top of the page
 
jleach
post Oct 28 2014, 06:31 AM
Post#17


UtterAccess Editor
Posts: 10,142
Joined: 7-December 09
From: St Augustine, FL


Glad to help ayen
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    14th October 2019 - 08:20 AM