473,412 Members | 2,994 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,412 software developers and data experts.

How to lock a control in a specific record or subset of records

Greetings,

I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes.

Three of the combo boxes ("FY", "Qtr" and "Mth") contain the values for a project's deadline: fiscal year, quarter and month, respectively, and are enclosed in an option group such that when the values for any of these three combo boxes are changed, an automatic change occurs to the value in a fourth combo box (named "cboStatus"), changing its value to a pre-determined setting (in this case, the word "Yellow").

Here's my challenge...

I want to lock the value in cboStatus following the AfterUpdate procedure to the option group. This is because I don't want someone to go back and change the status to its original setting after a date change. Furthermore, I want the value locked only for the specific record where the date changed. In other words, if I have 10 records in my table but only 2 whose date changed, I want the cboStatus to be locked for the two records only.

Everything I've tried thus far locks cboStatus for ALL records. Can I lock a control on a specifc record or subset of records?

Whatever advice anyone can offer would be greatly appreciated!
Feb 22 '08 #1
6 3629
Stewart Ross
2,545 Expert Mod 2GB
...I want to lock the value in cboStatus following the AfterUpdate procedure to the option group. This is because I don't want someone to go back and change the status to its original setting after a date change..
Hi. You could use the On Current event of your Project Update form to toggle the controls you don't wish to have updated to enabled=false and locked=true based on a condition testing the value of your status field (and any others you choose). Skeleton code for this in your On Current event is just

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim LockConditionMet as Boolean
  3. LockConditionMet = (specify the condition to be tested to determine whether to lock the values; condition true = lock, false = allow updates)
  4. me.firstcontrol.enabled = Not LockConditionMet 
  5. me.firstcontrol.locked = LockConditionMet
  6. me.secondcontrol.enabled = Not LockConditionMet
  7. me.secondcontrol.locked = LockConditionMet
  8. etc
  9.  
On Current is a record-level event that is fired each time you move from one record to another.

You would also call the On Current event in your After Update event, so that after a user updates values on your form the condition is tested to toggle controls on or off.

This will not prevent changes to individual values at table level if users have access to the underlying tables, however.

-Stewart
Feb 22 '08 #2
NeoPa
32,556 Expert Mod 16PB
This sort of question seems to come up a lot.
If I were to say that changing a setting on an individual instance of a control would be akin to redesigning a field in a table for a single record then hopefully you'll understand why it makes no sense at all.
Essentially the properties that you have access to (to change) are object properties and not instance properties. Instance meaning a single example of an object. The object being the design.
I hope this makes things a little clearer.
Feb 25 '08 #3
Delerna
1,134 Expert 1GB
or in other words
on a continuous form in design mode each column has 1 and only 1 control for displaying the data. When you run the form each column has multiple copies of that same single instance of the control. Changing the properties of that single instance means each column now still only contains mutiple copies of that single instance with the changed property.

Oh and good analogy NeoPa
Feb 26 '08 #4
mshmyob
904 Expert 512MB
You could DISABLE an individul control in a subform (whether it is continuous or not).

Keep in mind Access allows a MAXIMUM of 4 individul control changes only.

It is better known as the FORMATCONDITION collection.

To disable an individule control you would do something like this:

Expand|Select|Wrap|Line Numbers
  1. Dim objFrc As FormatCondition
  2. ' add a single format condition to a specific control based on its value (ie: does the current value of the control = varX)
  3. Set objFrc = Me![subFormName].FormatConditions.Add(acFieldValue, acEqual, varX)
  4. objFrc.Enabled = False
  5.  
Important to remember you can only do it for a maximum of 4 seperate 'controls'. So you would have to delete them or modify them to stop it from crashing.

cheers,
Feb 26 '08 #5
NeoPa
32,556 Expert Mod 16PB
Conditional formatting (as mshmyob describes) is possible to use. If you can find a detectable condition that matches your requirements. This is still applied across the object as a whole, however it's clever enough to determine the value of each one and apply formatting conditionally.
Feb 26 '08 #6
mshmyob
904 Expert 512MB
Oops I made a slight mistake in my last post code.

To apply your FormatCondition to 1 and only 1 control in your subform you would change the previous code to:

Expand|Select|Wrap|Line Numbers
  1. Dim objFrc As FormatCondition
  2. ' add a single format condition to a specific control based on its value (ie: does the current value of the control = varX)
  3. Set objFrc = Me![txtField].FormatConditions.Add(acFieldValue, acEqual, varX)
  4. objFrc.Enabled = False
  5.  
I changed 'subFormName' to 'txtField'. TxtField being the name of the text or combo control you want to disable.

Everything else I mentioned about only being able to apply 'different' formatconditions to only 4 individual controls still aplly.

I have done exactly what you are trying before where based on the selection in the combo box on each row of a continuous form I change the background color of a specific text box on that 1 row. It does not propogate down the whole column. I use it to just hilite a specific value based on a specific condition being met.

I will admit it took me a while to figure it out and stop it from changing my whole column.


cheers,
Feb 26 '08 #7

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

Similar topics

8
by: Bri | last post by:
Greetings, After making various edits and deletes on aproximately 40,000 records in one table (on the Design Master) syncronization fails with Error 3052 - File Sharing Lock Count Exceeded....
7
by: Saintor | last post by:
What I do now is I put a value in the tag property, and using the form_current event, I run through all controls properties until the ones with the required tag value are met. Sound OK in theory,...
14
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X +...
4
by: feng | last post by:
Hi, I know ADO.Net recommand using disconnected update (optimistic concurrency) for good reasons, but it's just not an option for us. 99% of our clients would rather seeing "record locked" kind...
8
by: Komandur Kannan | last post by:
We have a smart device application running on handhelds(Symbol MC9000G). The backend is Oracle and a middle tier web services development done in Vb.net. We use pessimistic Locking due to...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
5
by: payffl | last post by:
My users are running Access '03. They have a database with a form that allows them to enter new records. Frequently they will move to a new record and not enter any information. This prevents...
21
by: egaffney | last post by:
Hello Everyone, I am using Access 2003 to create a parts management system. I am looking to create a checkbox (or any other control) in a form that when checked by the user locks the current...
1
WyvsEyeView
by: WyvsEyeView | last post by:
I have a dataset subform on which I want to lock a field for just two specific records. Each record has a type_id and a desc field. I want to test the value of the type_id field for the current...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.