A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

lock specific distinct records



 
 
Thread Tools Display Modes
  #1  
Old April 3rd, 2005, 07:03 PM
Hatchet Harry
external usenet poster
 
Posts: n/a
Default lock specific distinct records

I need to be able to add an option for each record to lock it to prevent a
user from accidentially editing specific parts of it. For example each record
represents an invoice raised, but once sent certain fields (such as date and
amount) should not be edited or deleted. How can I do this?

Ideally I would like to add a "Lock" switch on the form so that I can always
turn this feature on or off with respect to this specific record at the users
discression.
  #2  
Old April 4th, 2005, 03:06 AM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Sun, 3 Apr 2005 11:03:02 -0700, "Hatchet Harry" Hatchet
wrote:

I need to be able to add an option for each record to lock it to prevent a
user from accidentially editing specific parts of it. For example each record
represents an invoice raised, but once sent certain fields (such as date and
amount) should not be edited or deleted. How can I do this?

Ideally I would like to add a "Lock" switch on the form so that I can always
turn this feature on or off with respect to this specific record at the users
discression.


It's not too hard to do this on a Form: have a yes/no field, Lock, in
the table, and use the Form's BeforeUpdate event to cancel the update
if the record is marked locked. E.g.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me.Lock Then
MsgBox "This record is locked for editing", vbOKOnly
Cancel = True
End If
End Sub

Or, you can put similar code in the BeforeUpdate event of each control
which should be frozen; or, even better, use the Form's Current event
to lock individual controls:

Private Sub Form_Current()
If Me.Lock Then
Me!txtInvoiceDate.Enabled = False
Me!txtInvoiceDate.Locked = True
Me!txtInvoiceDate.BackColor = vbYellow ' visual indicator
Me!txtAmount.Enabled = False
Me!txtAmount.Locked = True
Me!txtAmount.BackColor = vbYellow
Else
you get the idea

However, this will not prevent a user from opening a query or table
datasheet and doing what they want. The only way to block that is to
invoke Access Security on the database and make your form the only
venue in which users can touch the data.

John W. Vinson[MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IIF Statement to Count Specific Records TinleyParkILGal Setting Up & Running Reports 5 May 19th, 2006 08:05 PM
Count specific entries in records in report fed by xtab query Bill Pauley Setting Up & Running Reports 11 April 2nd, 2005 05:18 AM
Number of records by Month that meet a specific requirement Keith Brown Worksheet Functions 1 February 5th, 2005 05:42 PM
New records can't be seen rleblanc Using Forms 6 August 14th, 2004 02:43 PM
How to Manipulate the group and sorting in a report? Jorge Novoa Using Forms 2 June 9th, 2004 01:12 AM


All times are GMT +1. The time now is 01:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.