473,386 Members | 1,715 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,386 software developers and data experts.

Change a Record to Read Only

58
How can I change a record to Read Only? I have a Database (MS Access 2007) in a public folder, which many people have access to it and, we have no control over some of them to make unnecessary changes to fields or records. I was reading about setting the “Allow Edits” Property to False from a Form to avoid changes, but but I can’t find a way how to do it. Can anyone tell me if this is the best options and/or what the steps would be?
Any help is greatly appreciated.
Thank you in advance

plaguna
Apr 6 '09 #1
9 8940
ChipR
1,287 Expert 1GB
Setting the Allow Edits property is a fine way to lock the record. Note that "Changing a field value programmatically causes the current record to be editable, regardless of the AllowEdits property setting." from this reference. I would suggest reading all of that page anyway.

To find this property:
  • Open the form in design view
  • Open the Property Sheet
  • Make sure that "Form" is selected in the drop-down at the top of the Property Sheet
  • Select the Data tab
  • You will see Allow Edits toward the bottom of the list
If you don't have too many controls to worry about, or you only want to lock individual controls, you can set their Locked and/or Enabled properties for the same effect.
Apr 6 '09 #2
plaguna
58
Great information. Thank you.
Therefore, When I set the AllowEdits property to “No” It sets to all records of the Form, and my intension is to AllowEdits=No to only a specific Record. Also, I Added this code to the On Current event of my Form in order to set the AllowEdits Property based on the contents of the CompletionDate field in my form:
Private Sub Form_Current()
Me.AllowEdits = IsNull(Me.CompletionDate)
End Sub
That way if the field has a value, then set the AllowEdits property to false.
My problem is that even if this makes sense, It doesn’t work. No matter what I code to the On Current event of my form, If the AllowEdits property is set to NO, It always sets to all records and not to what I am trying to do; “AllowEdits Property to false to only one record”.
Thank you in advance for helping,

Plaguna
Apr 7 '09 #3
missinglinq
3,532 Expert 2GB
If the AllowEdits property is set to NO
Are you saying that you have AllowEdits set to No in the Properties sheet? It shouldn't be. With it set to Yes in the form's Properties and your code in place, it should work exactly as you want.

Linq ;0)>
Apr 7 '09 #4
ChipR
1,287 Expert 1GB
I put some code in a command button and used it to toggle the AllowEdits property. I found that toggling the property from True to False did not prevent me from editing the record. Until the reason for this is found, you can set all the individual controls to locked or unlocked.
Apr 8 '09 #5
OldBirdman
675 512MB
I did a similar test to ChipR, only I toggled in the OnCurrent event, testing one field to determine True or False. Neither condition prevented me from editing the selected record, and saving it. Access 2000 and Access 2002.
Apr 8 '09 #6
FishVal
2,653 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     With Me
  3.         .AllowEdits = (.key1 = 2)
  4.     End With
  5. End Sub
  6.  
works as expected in Access 2003.
[key1] is a textbox
Apr 8 '09 #7
plaguna
58
Please Tell me if I’m doing something wrong, because no matter what the code in the On Current event is, I’m still allowed to edit.
These are the steps:
1. Open the form with the record I want to lock
2. Change to Dedign view
3. Set the AllowEdits property on the form to Yes. (from Property Sheet, Data tab)
4. Set the On Current property (Event tab) of the form to the following event procedure:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.AllowEdits = IsNull(Me.CompletionDate)
  3. End Sub
  4.  
5. Save the form and open it in Form view.

Also, I changed the code to test if I’m allowed code to run and, there is no indication of code execution.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     MsgBox "Can you hear me now?"
  3.     Me.AllowEdits = IsNull(Me.CompletionDate)
  4. End Sub
  5.  
Is there a possibility for my Access 2007 not to allow code execution? I that would be the case, is there a way to enable it?

Thank you for your help

plaguna
Apr 10 '09 #8
plaguna
58
Good site but, it is not exactly what I am looking for. Thank you anyway.
plaguna
Apr 20 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Harry Pehkonen | last post by:
Stats: Python2.3 windows2000 professional If I have ``Full Control'' of a bsddb file, no problem: >>> import bsddb >>> a = bsddb.btopen("c:/sharedrw/db/npanxx2pseudo.db", "r") >>> a.close()...
1
by: Pranav Bagora | last post by:
Hello, I am getting a permission Denied error when i am trying to make changes in some read only files in a directory. How do we check and change the read only attributes of files in python. ...
1
by: Bruce Hendry | last post by:
In a nutshell, I have a stored proc that takes appx 15 minutes when it uses a read-only database, and about 2 minutes when the database is not read-only. Details: SQL Server 7 The stored...
4
by: Paul Malcomson | last post by:
I'm trying to finish implementing security on my database. I have secured the .mdb with a .mdw file as per the MS security FAQ with no problems. The last part of security that I need to...
3
by: Vic | last post by:
Dear All, I have a database of laboratory records in Access 2000. There is one form which acts as an interface to input experimetal data. This form incorporates information from several tables....
5
by: manokumar | last post by:
hiye, i notice that some if not all of my folders in winxp pro. are set as read only and its giving me some problem with development. so as the natural thing, i unchecked the read only option and...
4
by: Jim | last post by:
I have the following piece of code: Directory.CreateDirectory(myDir); DirectoryInfo lDir = new DirectoryInfo(myDir); lDir.Attributes = FileAttributes.Normal; When this code runs, my directory...
2
by: vidsenk | last post by:
hi i have a readonly textbox , which should be shown as normal textbox color. i tried to change the backcolor property, but not working. help me thanku sk
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
23
by: Dan Tallent | last post by:
A textbox has a attribute for ReadOnly. This seems like such a simple concept. When a textbox is set to read only the user cannot change the contents of the field. I have been trying to find...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.