473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

locking records on a form

Joe
Hi there, question regarding Access 2000 - locking records:
I want to be able to lock a record (or several records) on a form so
that particular record can not be edited until I undo the lock (im the
administrator and have a password). I want to be able to lock the
record on the form by pressing a button. Once the button is pressed a
flag appears which displays that particular record as locked. Can
anyone help with this?

Thanks, Joe
Nov 13 '05 #1
3 4647
jo*******@hotmail.com (Joe) wrote in message news:<74**************************@posting.google. com>...
Hi there, question regarding Access 2000 - locking records:
I want to be able to lock a record (or several records) on a form so
that particular record can not be edited until I undo the lock (im the
administrator and have a password). I want to be able to lock the
record on the form by pressing a button. Once the button is pressed a
flag appears which displays that particular record as locked. Can
anyone help with this?

Thanks, Joe


Nothing doing. Add a field to your underlying table. Something like
"AllowEditing" as a yes/no field. Then put the field on your form(s)
- for YOUR form, it will always be visible/enabled. On the form you
give others, it won't be visible/editable.

Then put code like this in the Current event of the form...

Private Sub Form_Current()
Me.AllowEdits = Not Me.chkRecordLocked
End Sub

(chkRecordLocked is the flag in my table.) Of course, you'll have to
view a single record at a time, though...
Nov 13 '05 #2
jo*******@hotmail.com (Joe) wrote in message news:<74**************************@posting.google. com>...
Hi there, question regarding Access 2000 - locking records:
I want to be able to lock a record (or several records) on a form so
that particular record can not be edited until I undo the lock (im the
administrator and have a password). I want to be able to lock the
record on the form by pressing a button. Once the button is pressed a
flag appears which displays that particular record as locked. Can
anyone help with this?

Thanks, Joe


One way - add a yes/no field to the underlying table, something like
"LockRecord".
Put this field on your form, but not visible (should show as a
checkbox). Then in the OnCurrent event of your form, do something like

Me.AllowEdits=me.chkLockRecord

which will toggle the lock On/Off.

The "admin" form will not have this yes/no field locked so it can be
edited.
Nov 13 '05 #3
pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>...
jo*******@hotmail.com (Joe) wrote in message news:<74**************************@posting.google. com>...
Hi there, question regarding Access 2000 - locking records:
I want to be able to lock a record (or several records) on a form so
that particular record can not be edited until I undo the lock (im the
administrator and have a password). I want to be able to lock the
record on the form by pressing a button. Once the button is pressed a
flag appears which displays that particular record as locked. Can
anyone help with this?

Thanks, Joe


One way - add a yes/no field to the underlying table, something like
"LockRecord".
Put this field on your form, but not visible (should show as a
checkbox). Then in the OnCurrent event of your form, do something like

Me.AllowEdits=me.chkLockRecord

which will toggle the lock On/Off.

The "admin" form will not have this yes/no field locked so it can be
edited.


That's a good idea, Pieter. I have a further suggestion. Instead of
creating two separate forms, you can put this code in a module...

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function GetUserName() As String
' Returns the network login name
' From: Dev Ashish
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
End Function

so that you can unlock and unhide the LockRecord checkbox when the
'Administrator' opens the form. That seems easier than having to
maintain an extra form. However, this function can take a second or
more to run so a separate form might be better if the form needs to
open quickly.

James A. Fortune
Nov 13 '05 #4

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

Similar topics

1
by: Justin | last post by:
Hello: I have a question regarding Record Locking in ASP...If the user x's out of the web page, how can I unlock the record? A co-worker told me it has to be done in Javascript, but he doesn't...
6
by: MS | last post by:
Access 97 here. I want a simple way to "lock" certain records on a form. Some records remain "live" until all data is available which happens over time. When all the fields are complete, I want...
1
by: ken | last post by:
Record locking is a form property which either locks the whole record when another user is accessing it, or just locks the cell that is being edited correct? I am looking for another record...
5
by: swapna_munukoti | last post by:
Hi all, Is there any tool to achieve record locking in MS Access 2000. Thanks, Swapna.
2
by: pj | last post by:
We are experiencing record locking errors which don't make sense. O/S :Windows 2003 Server running Terminal Services Access 2003 SP1 Front end copied to each user folder. 4 users adding...
8
by: paulwilliamsonremove | last post by:
Hi, Using Access 2003. I am trying to delete records from one table/query ("qryHistoryPersonIDs") if they don't exist in another table ("qryDonations"). But the SQL syntax I came up with is...
6
by: Trees | last post by:
I have a database that was created so that 4 separate shops could go in and enter pertinent information about how their shops ran throughout the day so that my boss (and theirs) could report out...
1
by: Michael728 | last post by:
Need some help please. There are 4 tables in this database. Six controls on the form are related to the table Degree. The other controls on the form are related to the other three tables. My...
3
by: kstevens | last post by:
I have turned on record locking do to the fact that we are starting to have issues with the records not being locked. I have a button on a form that changes the recordsource of the form. When i...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.