Lock Fields on Form and Subform Based On One Field Value (1 Viewer)

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
Hi,


I have a form AFRs that has the field 'Status'. Is there a way to lock all fields on the form and the subform AFRsParts when the Status field is "Closed"? Also a way to change the Status to "Open" and have the fields unlocked in case there needs to be changes made.


Thank you very much for your help


PS Hold down shift key to open the database showing the navigation pane if needed.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 06:17
Joined
Oct 29, 2018
Messages
21,449
Hi. Without looking at your database, the easiest way to lock a form is by setting the AllowEdits property to False/No. But if AllowEdits is No, then you'll need another way to modify the data to unlock the form.
 

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
Thanks but I was hoping for a solution.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:17
Joined
Oct 29, 2018
Messages
21,449
Thanks but I was hoping for a solution.
Sorry, I'm not in a position to download your file at the moment. Hopefully someone else will be able to help you out. Good luck!
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:17
Joined
Jul 9, 2003
Messages
16,271
I have undeleted this thread because it is a general policy of this forum that posts/threads should not be deleted, especially if someone has taken the time and trouble to answer you. The fact that you did not find the answer helpful is no reason to delete it, and at best demonstrates a certain amount of impatience on your part.

It is a very common question, how to make various form objects editable or not, so I would suggest you do a bit of searching of the forum.

Colin, (Handle isladogs) has some useful examples of this type of thing which I believe you can find on his website here:-

Set Controls

Extract:-
The attached utility demonstrates a way of setting the state of a group of controls at the same time using the controls' Tag property.

Image of Colin's Example:-




I also provide some information on my website here:- Lock, Unlock Controls >>>> and Here:- Loop Through a Set of Controls..
 

Attachments

  • 4634989165[1].png
    4634989165[1].png
    77.5 KB · Views: 730
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:17
Joined
Jul 9, 2003
Messages
16,271
I was looking back through your threads to see if you had deleted any others, and I note that you recently had a 7-day ban. I'm wondering if that explains your preference for deleting your threads?

If you're feeling a bit tetchy because you've had a ban then, I suggest you find some other way of venting your frustration. There is a very good section of the forum called the "Water cooler" where you can get away with just about anything as long as you don't break the law. Get along there and yell and curse and shout and get it out of your system.

Alternatively watch a bit of Dr Jordan B Peterson, he has got some excellent ideas on how you can steer yourself away from going down the nihilistic route...
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:17
Joined
Jul 9, 2003
Messages
16,271
Too complicated for me sorry
Yes, you are right it is difficult! It's always difficult learning new code, new ways to do things.

However this forum is full of people that have been through that learning process, people that have committed themselves to helping others through the same process.

if you want to learn MS Access, then these people will step in wherever they can and show you the way.

If you post your database and say "fix this", then it is unlikely you will get any help. The main reason being, if someone does the work for you, then you're not going to learn. And that's what this forum is about helping people learn how to use MS Access.

The second problem, and this is more difficult for you to grasp as a beginner, it's not easy looking at someone's database ferreting out the problem, and providing a solution. Even if the database is built along the recommended lines, and everything is functioning correctly, adding a piece of code will take at least half an hour, time that is much better spent showing the prospective database developer how to do it themselves.

Finally, the public nature of the forum, the process of you asking a question, and receiving an answer makes the knowledge available to everyone. For every person stuck and asking a question, I should imagine there are at least 10 others that solve the same problem by reading your questions and the answers given.

So don't give up, tackle it in small chunks. you could begin by creating a small sample database, extract some code from Colins example, and apply that code within your example.

Keep doing that until you run into a problem and then post the sample database along with an explanation of what you were trying to make happen and what actually happened, and then you will get some help.

Sent from my Pixel 3a using Tapatalk
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 23:17
Joined
Jan 20, 2009
Messages
12,851
Too complicated for me sorry

I would suggest you consider another line of work if you think this simple task is too difficult to attempt yourself. You won't learn anything by getting someone to do it for you. Nor will it bring you real job satisfaction.

Although we do sometimes write code for people, the main purpose of this forum is to share knowledge and instill understanding. When I rarely do write code is when it is an interesting challenge or I have a purpose for it for my own work.

Complaining that you didn't instantly get what you wanted handed to you on a plate is a really quick way to eventually get ignored. Don't forget we are all volunteers here.
 

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
So far I have been criticized for not being able to post a proper question and this last one giving me advice to change my line of work.


I have managed to make a database that has been working for the last 5 years. I am just trying to improve the system by asking so-called experts on here.


I believe at this point I will not receive any easy guidance. If I were in the position of helping others on here that are in apparent need I would be more patient. However this is not the case and it seems that it's best that I learn on my own how to improve my system.
 

Vassago

Former Staff Turned AWF Retiree
Local time
Today, 09:17
Joined
Dec 26, 2002
Messages
4,751
You didn't ask for guidance. You only stated it was too complicated for you. So ask for guidance! What part is too complicated? Did you look at the design and come up with questions? That's a better way to seek help than "Thanks but I was hoping for a solution."

We are here to guide you to the answer you seek, but not do it for you, as others have already stated. People here are happy to help guide you, but generally will ignore you if you are unwilling to take another step on your own and come back with questions.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:17
Joined
Sep 21, 2011
Messages
14,223
I have managed to make a database that has been working for the last 5 years. I am just trying to improve the system by asking so-called experts on here.

I am in the same position that you are in. I have in the past created some DBs for use in work, that worked fine thanks to assistance from here, but now out of work, still use Access for my charity work and my own personal uses.

I have received assistance on here since 2011 for those DBs' and still get it when I ask.?

I take on board what you so insolently call 'so-called 'experts' advice when I post. I also take on board what they post for others.
Sometimes it has not been what I wanted to hear as I was too far down a certain path with structure being logically incorrect, but I still appreciated their input. After all why bother asking if you are not going to listen.?

That input was incorporated in future projects when required so I did not make the same mistake twice. I try to learn by my mistakes.

You appear to have a huge chip on your shoulder? If you were to leave it at the keyboard and try an treat others as you would wish to be treated, I am sure you would benefit greatly from this site.

However it is up to you.?
 

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
Hello,


I humbly ask for your help please. I have a form AFRs that I would like the ability to close all fields for editing including the subform AFRsParts for the records that have "Closed" in the Status field. Does anyone know how to go about doing this?


Thank you kindly,
Bill
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 14:17
Joined
Sep 21, 2011
Messages
14,223
I *think* the easiest way would be to disable AllowEdits for the form and subform

Place the code in the current event of the main form checking the Status control
Bear in mind I am not an expert, so the syntax might not be perfect for the subform?

Code:
Me.AllowEdits = Me.Status <> "Closed"
Me.SubFormControl.Form.AllowsEdits = Me.Status <> "Closed"

HTH
 

isladogs

MVP / VIP
Local time
Today, 14:17
Joined
Jan 14, 2017
Messages
18,209
A variation on the same theme...
In form current event, put

Code:
If Me.Status="Closed" Then
   Me.AllowEdits=False
   Me.SubFormControl.Form.AllowsEdits=False
Else
   Me.AllowEdits=True
   Me.SubFormControl.Form.AllowsEdits=True
End If

NOTE:
1. The subformcontrol lines may not be needed as it should I think be locked automatically along with the main form
2. Substitute the actual name of your subform control

Alternatively, you could use the tab property as in my example database mentioned back in post #5 by Uncle Gizmo

BTW I agree fully with the previous comments by other forum members.
Rather than appearing to ignore them, it would be a good idea to acknowledge the points made and try to act upon the constructive advice given by several of our most experienced and knowledgeable forum members
 
Last edited:

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
I am getting compile error (it highlights Status)



Private Sub Form_Current()
Me.AllowEdits = Me.Status <> "Closed"
Me.AFRsParts.Form.AllowsEdits = Me.Status <> "Closed"
End Sub
 

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
I am not sure what subform it is maybe that's the problem? How can I look at the tab in design view and identify the name of the parts source for the code.


I thought it was AFRsParts
 

billgyrotech

Banned
Local time
Today, 08:17
Joined
Apr 18, 2013
Messages
258
I commented out the lines for the subformcontrol and it will lock the main form fields but the parts are still open for editing.


Can you please take a look at the file to see how to identify the parts form so it can be included in the code?


Thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:17
Joined
Oct 29, 2018
Messages
21,449
Hi Bill. Pardon me for jumping back in, but it looks like we have gone back into full circle on this topic. Modifying the AllowEdits property was the same approach I suggested at the beginning of this thread. Please take a look at the attached modified version of your db and let us know if this is close to what you wanted. Cheers!
 

Attachments

  • AFR System 12.1.zip
    1.1 MB · Views: 115

Users who are viewing this thread

Top Bottom