lock a single field in ado recordset

Posted on 2004-11-03
Medium Priority
Last Modified: 2013-12-25
Someone know if are possible to lock a single field in ado recordset?
Question by:francecap
  • 3
  • 3
  • 2
  • +2
LVL 70

Expert Comment

by:Éric Moreau
ID: 12481729
You cannot lock less then a row and very often a page (many rows) are locked.

Author Comment

ID: 12481859
with some expedient to code livel?

Expert Comment

ID: 12485767
Can you tell us what you are trying to achieve?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12485906
I want to lock recordset field ex:
rst.fields(1) [locked]
rst.fields(2) [not locked]
the use of control binded to rst.fields(1) are not possible, like locked=true property of textbox Microsoft
the use of control binded to rst.fields(2) are possible, like locked=false property of textbox Microsoft

note that I have control non stadard Microsoft, that not has locked property!

LVL 70

Expert Comment

by:Éric Moreau
ID: 12486064
I think you are mixing 2 concepts:
1. locking control on the screen
2. locking fields in the database

1. Which control is it? Do you have the Enabled property?
2. This cannot be done on a field basis.

Expert Comment

ID: 12489857
Here is what I would do, and it works with Access, and it should also with ADO.

Create a query for your able, and to lock certain fields make them calculated field with an alias.  Example:

SELECT EmailAddress, FromAddress & "" AS TheAddress FROM Table1

You will be able to edit the EmailAddress field but not "TheAddress" field.

Good luck.

Chris Lewis
LVL 70

Expert Comment

by:Éric Moreau
ID: 12492089
>>You will be able to edit the EmailAddress field but not "TheAddress" field.

The asker seems to want to lock it on screen. This method will only lock the database update, not the screen.

Accepted Solution

kellysys earned 1000 total points
ID: 12492099
what control are you using here?

it may have other properties like "controltype" that can be used.

in any case you could put your control on top of a container like a picture box or a frame, you could disable that in code. That would have practically same effect.  you wont be able to click into control at all. only problem is if you wish to have copy to clipboard from that control.
LVL 12

Expert Comment

ID: 12552916
It seems like you're using a "Page-Level" locking where two or more records are locked when a user invokes an Edit operation.
Try this method (if using an Access Database). This should eliminate the problem.

 Dim oCN As ADODB.Connection

 Set oCN = New ADODB.Connection
 oCN.Provider = "Microsoft.JET.OLEDB.4.0"
 oCN.Properties("Data Source") = "C:\Temp\MyDB.mdb"
 oCN.Properties("Jet OLEDB:Database Locking Mode") = 1      '<-- This enforces a "Record-Level" locking
 oCN.CursorLocation = adUseServer

Expert Comment

ID: 12591728
Glad to be of assistance

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question