473,513 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't locked field keep its property ONLOAD?

58 New Member
Hi again!
I have a button on the Form to set allfields in a form to LOCKED. By setting the Event atOnClick_Event as:
Me.FieldName.Locked=True
When pressing the Button(Command67) all fields are LOCKED as EXPECTED. But if you Close the form and ReOpen it again you will find all form field are UNLOCKED and not LOCKED as before.
How should I keep it with its latest saved values and properties?
Oct 31 '10 #1
8 1929
ADezii
8,834 Recognized Expert Expert
  1. Create a Public Variable in a Standard Code Module to indicate what the Locked Status of the Fields should be.
    Expand|Select|Wrap|Line Numbers
    1. Public blnFieldsAreLocked As Boolean
  2. Create a Form Level Sub-Routine in the Form's Code Module that will Control the Locking and Unlocking of Fields on the Form.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub LockFields(blnLock As Boolean)
    2. On Error Resume Next
    3. Dim ctl As Control
    4.  
    5. For Each ctl In Me.Controls
    6.   ctl.Locked = blnLock
    7. Next
    8. End Sub
  3. To LOCK all Fields on the Form:
    Expand|Select|Wrap|Line Numbers
    1. blnFieldsAreLocked = True     'Set Public Variable to True
    2.  
    3. Call LockFields(True)
  4. To UNLOCK all Fields on the Form:
    Expand|Select|Wrap|Line Numbers
    1. blnFieldsAreLocked = False     'Set Public Variable to False
    2.  
    3. Call LockFields(False)
Oct 31 '10 #2
Moah Scout
58 New Member
Thanks!
But I couldnt find the way out on where and why should I place the Code?
Give further details please?
Nov 1 '10 #3
NeoPa
32,557 Recognized Expert Moderator MVP
From your question you seem not to realise that property changes to a running form are transitory, and do not cause the design of the form itself to be changed. I expect you need to consider the ramifications of changing the project design to handle a transient situation for an operator, as it isn't generally a good idea (with a little thought that should be pretty obvious).

If you absolutely need this to be remembered from one session to the next then you could consider storing the information that pertains to the state, and for which operator it's related to, in a table and reading the table when the form is opened so that the transitory state of the running form matches what you expect, without the form design requiring any changes.
Nov 1 '10 #4
ADezii
8,834 Recognized Expert Expert
Hello NeoPa, I thought that the question only related to the Opening and Closing of a Form within the Current Session, and not from Session to Session. If I'm wrong, than the change can easily persist by writing the Locked State to the Registry or Hidden Table upon Form/DB Close, No?
Nov 1 '10 #5
Moah Scout
58 New Member
I couldnt catch your conversation!
How should it be handled then? Please!
Nov 2 '10 #6
NeoPa
32,557 Recognized Expert Moderator MVP
Moah Scout:
But if you Close the form and ReOpen it again you will find all form field are UNLOCKED and not LOCKED as before.
ADezii,

From the text quoted from the OP, I believe Moah is saying he wishes changes to be maintained across sessions. If this were to be done, then using the Registry would not be recommended (bearing in mind this is an RDBMS after all) but a simple table (no reason for System or Hidden) could do the job. This would not be considered easy for anyone that wasn't pretty experienced, but could certainly be achieved (I'm sure you could manage it with your eyes closed).

The more important point of my post though, was about the advisability of handling anything this way. It is fundamentally unsound and can lead someone into uncharted territory further down the line (especially someone whose experience is clearly limited). This is why I urged for a reconsideration of the design. Would it be helpful to show someone how to get themselves deeper into trouble? It seems not to me.

@Moah,
Sorry to converse around you. For you I say forget about trying to do what you are doing that way. Give more consideration to exactly what you are trying to achieve and find an approach that doesn't involve the project reconfiguring itself on the fly. Perhaps if you shared what you're actually hoping to achieve, we could help in that area.
Nov 2 '10 #7
ADezii
8,834 Recognized Expert Expert
@NeoPa - Points well taken, thanks.
Nov 2 '10 #8
Moah Scout
58 New Member
Thanks Adezii!
Let us do the technical parts of it.
How could this simple design be achieved?
Nov 2 '10 #9

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

Similar topics

3
3316
by: Max | last post by:
Hi, I am trying to convert string entered in a field to uppercase using its formula property. I know it can be done using trigger but still I want to use formula property to achieve the same. ...
1
2023
by: reneecccwest | last post by:
hello, is there any way to indicte a cursor on the first text user input when a page loads without using onload in the body tag?
4
2078
by: Gawel | last post by:
Let say I have: public class Class1 { protected int _counter; public void MakeSomethingWithCounter() { _counter = 10; or <--------------------------which way is morr accurate ?
5
13645
by: Vicky via DotNetMonster.com | last post by:
Hi, I need help with "An object reference is required for the nonstatic field, method, or property 'dataReader.Class1.data'" Before I put folowing variable in class level, it works fine....
3
4186
by: SteveM | last post by:
I have a locked field on a tabular form that maps to a lookup table. However, since the field is view only, I'd like to remove the lookup dropdown arrow. Any ideas. Thanks, SteveM
1
6018
by: mIDO | last post by:
Hello, I have developed a script that change the font size in css, but only the attribute "font-size" on the body tag, not change the entire active stylesheet. When i click to change the size...
2
14235
by: Mike | last post by:
ASP.NET 2.0 I have some code working in a code-behind that I want to move to a utility class. In the code behind, I can reference the querystring and get the Page value easily. However, when...
2
2000
by: rameshonweb | last post by:
Iam getting the error an object reference is required for the nonstatic field method or property 'System.Windows.Forms.Control.CreateGraphics()' for this part of code public static void...
2
4742
by: shalskedar | last post by:
I 've created Report in Ms access which contains subform.The field value in the report is retrieved from the subform.When this report is exported,it shows the error as The expression you entered has...
1
8592
by: Rach26 | last post by:
Hello I am currently developing my masters project and am relativly new to C# I am having a problem with my Cache. In settings.settings I have placed the following after my connection setting: ...
0
7257
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
7157
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
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
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
5682
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
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.