Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-15-2019, 03:16 AM   #16
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,921
Thanks: 114
Thanked 2,986 Times in 2,715 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Lock Fields on Form and Subform Based On One Field Value

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

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by isladogs; 06-15-2019 at 03:18 AM. Reason: Fixed error
isladogs is offline   Reply With Quote
Old 06-15-2019, 03:27 AM   #17
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

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 is offline   Reply With Quote
Old 06-15-2019, 03:33 AM   #18
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

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 is offline   Reply With Quote
Old 06-15-2019, 03:53 AM   #19
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

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
billgyrotech is offline   Reply With Quote
Old 06-15-2019, 06:50 AM   #20
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,650
Thanks: 56
Thanked 1,245 Times in 1,226 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Lock Fields on Form and Subform Based On One Field Value

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!
Attached Files
File Type: zip AFR System 12.1.zip (1.13 MB, 5 views)
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 06-15-2019, 07:18 AM   #21
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

Thank you DBguy,


It does lock the main form and subform however there a few things that I noticed:


1) I cannot add "New" record
2) Since I can't add the new record I cannot add Customers, Part Numbers, or Descriptions. There are Add buttons next to the fields.
3) I also found that I cannot search records by the drop down in the header.


Can you please take a look?


I appreciate any help
billgyrotech is offline   Reply With Quote
Old 06-15-2019, 07:27 AM   #22
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,650
Thanks: 56
Thanked 1,245 Times in 1,226 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Lock Fields on Form and Subform Based On One Field Value

Quote:
Originally Posted by billgyrotech View Post
Thank you DBguy,

It does lock the main form and subform however there a few things that I noticed:

1) I cannot add "New" record
2) Since I can't add the new record I cannot add Customers, Part Numbers, or Descriptions. There are Add buttons next to the fields.
3) I also found that I cannot search records by the drop down in the header.

Can you please take a look?

I appreciate any help
Hi Bill. Just as a quick fix, try the attached updated copy. You should be able to add new records now. I'll see what I could do with the search drop down.
Attached Files
File Type: zip AFR System 12.1.zip (1.13 MB, 5 views)

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 06-15-2019, 07:31 AM   #23
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,650
Thanks: 56
Thanked 1,245 Times in 1,226 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Lock Fields on Form and Subform Based On One Field Value

Quote:
Originally Posted by billgyrotech View Post
Thank you DBguy,

3) I also found that I cannot search records by the drop down in the header.


I appreciate any help
Okay, try this one. I'm on my way out of the office right now, so I'll check back in later.
Attached Files
File Type: zip AFR System 12.1.zip (1.13 MB, 4 views)
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 06-15-2019, 07:36 AM   #24
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

There may be more issues but I tried to go through adding a new record. There will only be some fields filled out by the Clerk and then the Tear Down report gets printed. This will be a traveler that stays with the unit that is need of repair.


So when I tried to close the AFR after this initial data entry process the popup says a related field is required for all the drop downs one at a time. The Dispositions is one in particular that isn't filled out until the repair is closed.


I am not sure how to stop these popups and accept the partial entries.


Do you know why?
billgyrotech is offline   Reply With Quote
Old 06-15-2019, 07:55 AM   #25
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,650
Thanks: 56
Thanked 1,245 Times in 1,226 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Lock Fields on Form and Subform Based On One Field Value

Quote:
Originally Posted by billgyrotech View Post
There may be more issues but I tried to go through adding a new record. There will only be some fields filled out by the Clerk and then the Tear Down report gets printed. This will be a traveler that stays with the unit that is need of repair.

So when I tried to close the AFR after this initial data entry process the popup says a related field is required for all the drop downs one at a time. The Dispositions is one in particular that isn't filled out until the repair is closed.

I am not sure how to stop these popups and accept the partial entries.

Do you know why?
Hi. I looked at your original file again and it seems this issue is not related to the code I added. Meaning, this problem is a separate issue to the one we were discussing in this thread. I'll have to take a deeper look into the form's design to be able to answer this particular question. I'll do that when I get back from my appointment.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by theDBguy; 06-15-2019 at 08:22 AM.
theDBguy is offline   Reply With Quote
Old 06-15-2019, 08:03 AM   #26
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

Thanks Mr. DBguy
billgyrotech is offline   Reply With Quote
Old 06-15-2019, 08:14 AM   #27
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

The initial data entries for new records are made in these fields:


AFR Number
SO Number
Clerk
Customer
Description
Part Number
Serial Number
Customer Complaint
Preliminary Inspection
Warranty (default should be unchecked)

Proper ID (default should be checked)

Hidden Damage (default should be unchecked)

Checked ADs (default should be checked)

Checked SBs (default should be unchecked)


The Status field should be "Open" for New Records.


I was able to set the defaults for these fields.


Thanks for any help

Last edited by billgyrotech; 06-18-2019 at 12:33 PM.
billgyrotech is offline   Reply With Quote
Old 06-15-2019, 10:42 AM   #28
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,319
Thanks: 431
Thanked 787 Times in 764 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: Lock Fields on Form and Subform Based On One Field Value

Quote:
Originally Posted by billgyrotech View Post
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
OK, that would be me. You stated that you wanted to check the Status control.?

However, I see you are in good hands so I will bow out.
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 06-15-2019, 10:51 AM   #29
billgyrotech
Banned
 
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Re: Lock Fields on Form and Subform Based On One Field Value

I think DBguy addressed that issue but there are more complications. He is checking into it when he has time.


Thank you
billgyrotech is offline   Reply With Quote
Old 06-15-2019, 11:05 AM   #30
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,650
Thanks: 56
Thanked 1,245 Times in 1,226 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Lock Fields on Form and Subform Based On One Field Value

Quote:
Originally Posted by billgyrotech View Post
The initial data entries for new records are made in these fields:


AFR Number
SO Number
Clerk
Customer
Description
Part Number
Serial Number
Customer Complaint
Preliminary Inspection
Warranty (default should be unchecked)

Proper ID (default should be checked)

Hidden Damage (default should be unchecked)

Checked ADs (default should be checked)

Checked SBs (default should be unchecked)


The Status field should be "Open" for New Records.


I was able to set the defaults for these fields.


Thanks for any help
Okay, I clicked on the New button and filled out the form as follows:
AFR Number = 111
SO Number = 111
Clerk = Xenobia Harvey
Customer = 21 Computer
Description = 21 Computer
Part Number = 13A655
Serial Number = 111
Customer Complaint = TEST
Preliminary Inspection = TEST
Warranty = unchecked
Proper ID = checked
Hidden Damage = unchecked
Checked ADs = checked
Checked SBs = checked
Status = Open


At this point, I am not sure what to do next. I don't see a Save button. How would I see the error message you mentioned earlier?

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
lock field in record based on input from another field murray83 Modules & VBA 4 06-10-2017 09:52 AM
need to lock button based on subform HRakibul Forms 12 09-02-2014 11:20 AM
disable / lock fields on form & subform based on checkbox fibayne Forms 7 02-16-2014 02:09 PM
lock a field on main form if a field on a subform is complete? KevinSlater Forms 4 10-26-2005 12:00 PM




All times are GMT -8. The time now is 07:59 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World