Lock all Field until Certain Field is Entered

harky

Active Member
Joined
Apr 8, 2010
Messages
405
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
I like to Lock all Field until Certain Field is Entered.
is there anyway to do it?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
In design mode ,set all the field property LOCKED =true. (Except the 1)
then in the 1 field, in the AFTERUPDATE event, then unlock all other fields ....
Code:
sub txtBox_afterupdate()
Txtbox2.locked= isNull(txtBox1)
txtbox3.locked=txtbox2.locked
txtbox4.locked=txtbox2.locked
end sub
 
Upvote 0
ahhhhh thanks but sorry i think i confuse.
Which should i set if i want to lock all expect StudentID is entered.

I try this but it did not unlock

Private Sub StudentID_AfterUpdate()
txtbox2.Locked = IsNull(StudentID)
Student_Name.Locked = txtbox2.Locked
Gender.Locked = txtbox2.Locked
DOB.Locked = txtbox2.Locked
Home_Phone.Locked = txtbox2.Locked
Mobile.Locked = txtbox2.Locked
Address.Locked = txtbox2.Locked
Postal.Locked = txtbox2.Locked
Note.Locked = txtbox2.Locked
End Sub



In design mode ,set all the field property LOCKED =true. (Except the 1)
then in the 1 field, in the AFTERUPDATE event, then unlock all other fields ....
Code:
sub txtBox_afterupdate()
Txtbox2.locked= isNull(txtBox1)
txtbox3.locked=txtbox2.locked
txtbox4.locked=txtbox2.locked
end sub
 
Last edited:
Upvote 0
Hi,
I had an error @ txtbox2.Locked = IsNull(StudentID)
 
Upvote 0
What is the error?
Also why do this? If you have users who try to enter student information without student ID's they will quickly learn by experience that that is a stupid thing to do (because it just won't work). No need for complicated code that is unnecessary.
 
Upvote 0
I had a popup debug error which highlight this

txtbox2.Locked = IsNull(StudentID)

the reason is because i using subform.
I cant add new item in my subform without input StudentID first tht y i was to force user to input StudentID before go to next step.

hehe i doing this for my project :/

What is the error?
Also why do this? If you have users who try to enter student information without student ID's they will quickly learn by experience that that is a stupid thing to do (because it just won't work). No need for complicated code that is unnecessary.
 
Last edited:
Upvote 0
You probably should not have things like student name in a subform. It's part of the student record, not a child of the student record. Locking fields is not a typical requirement for access development of forms. Naturally, once you are familiar with design principles you can do whatever you like but at first try to use the forms in a standard way and don't use a lot of code.
 
Upvote 0
is not student name.

Is an option of 4 diff COURSE table
E.g one student can take more than 2 course.
a Enrolment table


You probably should not have things like student name in a subform. It's part of the student record, not a child of the student record. Locking fields is not a typical requirement for access development of forms. Naturally, once you are familiar with design principles you can do whatever you like but at first try to use the forms in a standard way and don't use a lot of code.
 
Last edited:
Upvote 0
Okay. I guess I thought you had fields for student name because of the field that you named Student_Name. My bad!
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,289
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top