Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

locking particular rows on database table

Status
Not open for further replies.

VickyWinters

Technical User
Jun 6, 2002
9
0
0
US
Hi

Is there a way to lock a particular row on the database table?

I have 4 particular rows in a table that I do not want accidently changed or deleted. The other rows must remain open for editing.

Is there a way to do this?

 
Vicky,

One way to do what you want is as follows:

(a) Ensure that you have a field on your form which is unique for every record (it may be hidden). I'll assume that this field is called RecordId.

(b) I will assume that the records that you want to protect have the RecordId field set to "RecA", "RecB", "RecC" and "RecD" respectively, and that you have set these up before hand.

(c) Place the following code in the On Current event of the form:

Dim F as Form: Set F = me
If F!RecordId = "RecA" OR _
F!RecordId = "RecB" OR _
F!RecordId = "RecC" OR _
F!RecordId = "RecD" Then

F.AllowAdditions = False
F.AllowDeletions = False
F.Edits = False
Else
F.AllowAdditions = True
F.AllowDeletions = True
F.Edits = True
Endif

With this method, the identifying field of each record will be examined as the record is loaded into the form, and the form "locked" if the current record is one of your four protected records.

Hope this helps,
Cheers,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top