473,378 Members | 1,439 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,378 software developers and data experts.

Subform locked / disabled fields

11
Hi,

Re: Controlling fields in a subform from a combo list value

Field names:
cboActivity - this combo box lists the Activity Numbers (i.e 1.1, 1.2, 1.3, 2.1, 2.2, 3.1)
txtStartDate - this date field is an input field
txtEndDate - this date field is an input field
txtQuantity - this text field is an input field
txtStartDepth - this text field is an input field
txtEndDepth - this text field is an input field

Goal / Solution Required:
I would like the subform to lock the last three text fields (txtQuantity, txtStartDepth, txtEndDepth) on load. I would like to enable these 3 fields for input based on the "cboActivity" value.

The following condition to enable the text fields are:

Condition 1:If "cboActivity" starts with a "1", then enable the txtQuanity field,
Condition 2:If "cboActivity" starts with a "2", then enable the txtStartDepth and txtEndDepth field,
Condition 3:If "cboActivity" starts with a "3", then enable the txtQuantity, txtStartDepth and txtEndDepth fields,

Help appreciated.
Nov 4 '10 #1
6 4513
mshmyob
904 Expert 512MB
Just subscribing. Will check in later. (weekend you know - lol)

cheers,
Nov 5 '10 #2
slenish
283 100+
Hello dekk,

I just have a couple questions first. The combo box that you want to be the main control point from switching the boxes from locked to unlocked is that in the Main Form or the subForm?? Also is the subForm always visible with in the Main Form?

With a little more information I can help you out.

:D
Nov 6 '10 #3
dekk
11
Hi Guys,

Firstly, thanks for your replies.

I have progressed a little and performed the steps below and receive the error
Expand|Select|Wrap|Line Numbers
  1. "You cannot disable a control while it has the focus".
Furthermore, when I review an existing record in the subform with the following code below, all of the fields are active.

I would assume that based on the combo list value together with the code below that the appropriate fields are locked/disabled?

Please note: the combo is named cboAct, not cboActivity as described in original post.

The "cboAct" (combo box field) is in the subform, not the main form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current() 
  2.     SetEnabledFields 
  3. End Sub 
  4.  
  5. Private Sub SetEnabledFields() 
  6.     Select Case Fix(Me.cboAct.Value) 
  7.     Case 1 
  8.         Me.txtStartDepth.Enabled = True 
  9.         Me.txtEndDepth.Enabled = True 
  10.     Case 2 
  11.         Me.txtQuantity.Enabled = True 
  12.     Case Else 
  13.         Me.txtStartDepth.Enabled = False 
  14.         Me.txtEndDepth.Enabled = False 
  15.         Me.txtQuantity.Enabled = False 
  16.     End Select 
  17. End Sub 
  18.  
What steps did I undertake?

1. The code above has been loaded in the subforms "on current" event (as you can tell by the procedure which is named "Private Sub Form_Current()"

2. The cboAct (combo box) field sources from a text field, not an integer. Thus, I have used the text solution using "fix" statement.

Confirmations:
1. The subform name is "tbl_TimeData". (obtained when putting main form in design mode and selecting subform).

Again, thanks for the assistance.

If the code above is way off, I am happy to put an alternative solution in from your suggestions.
Attached Files
File Type: zip Database1.zip (393.8 KB, 134 views)
Nov 6 '10 #4
dekk
11
Hello Slenish,

Please see my detailed reply. Answers to your question.

1. The combo box is in the subform and controls which subform fields are enabled/disabled.
2. The subform is always visible.
Nov 6 '10 #5
mshmyob
904 Expert 512MB
Hello dekk,

I looked at your database but it is not exactly what you are talking about in your previous code.

But anyways your cboAct Current Form event should be like so:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3. Me.txtStartDepth.Enabled = False
  4. Me.txtEndDepth.Enabled = False
  5. Me.txtQuantity.Enabled = False
  6.  
  7. Select Case Left(Me.cboAct.Value, 1)
  8. Case "1"
  9.     Me.txtStartDepth.Enabled = True
  10.     Me.txtEndDepth.Enabled = True
  11. Case "2"
  12.     Me.txtQuantity.Enabled = True
  13. Case Else
  14.     Me.txtStartDepth.Enabled = False
  15.     Me.txtEndDepth.Enabled = False
  16.     Me.txtQuantity.Enabled = False
  17. End Select
  18. End Sub
  19.  
NOTE: You have to reinitialise your controls to not enabled before you check for the cboActivity value and then set the appropriate controls enabled.


Also note that the database you uploaded had EndDepth named wrong and your reference to the controls were incorrect.

This fixes the problem of enabling/disabling for the database you uploaded.

If you have made other changes and getting new problems you need to show us your latest code.

cheers,
Nov 6 '10 #6
dekk
11
NOTE: You have to reinitialise your controls to not enabled before you check for the cboActivity value and then set the appropriate controls enabled.

[dekk] I see that this is performed in lines 3,4,5.

Also note that the database you uploaded had EndDepth named wrong and your reference to the controls were incorrect.

[dekk] I will check the control names. Thank you for taking the time to review the database.

I noticed you have used the left() function. The database will have a combo value between 1.1 to 20.6.

Can I substitute the let() function with Fix() to overcome the limitation of using left() with capturing the first prefix (1.1 = Case1, Case 10.1 = Case 1)?

[dekk] I haven't made any changes since replying to the post. I will check the code with the database when at work tomorrow.

At home today, crook :)

Thanks for your time. I will update the post once I have had the chance to review at work.
Nov 7 '10 #7

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

Similar topics

1
by: Ittay Dror | last post by:
Hi, I have a form with various elements which, according to changes in values become enabled or disabled. The disabled elements are normally not submitted, but I wish they were. How can I go...
3
by: sylvestre | last post by:
Hi, I've a little script that disables/enables some fields in a form. It works correctly, no problem. Problem arise when a disabled field becomes enabled again: the enter key pressed in that...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
2
by: Wayne | last post by:
I've implemented the following successfully on a single form before, but the continuous form is giving me problems. I have 2 combo boxes, Combo 1 and Combo 2. The values in Combo 2 are dependent...
1
by: Oliver Gabriel | last post by:
Hi, i have a form linked to a table. Because it is a very large form, i placed a tab control in it with sub-forms, that correspond to the same table. If i link them with the primary key...
3
by: Bubba Gump | last post by:
I hope someone can help here. I'm creating a form that disables certain fields depending on the users choices. But I've noticed that Disabled fields aren't "grayed out" (ie: you can't tell they're...
1
by: John | last post by:
Hi, I have a subform with some fields in them. i only want a customer to enter a property ID, so how can i stop the user from editing the customer ID, quantity, etc... how can i stop the user...
3
by: mycall | last post by:
I had a quick look but couldnt find much on this. What i have is a contiunous form with each row having an 'edit' button. By default all feilds have been set to disabled to stop the user...
51
AccessIdiot
by: AccessIdiot | last post by:
Hi there, I would like to put a button on my form that enables or unlocks the subform and at the same time disables (locks) the main form until the user is done with the subform. At that point the...
0
by: Gordon Padwick | last post by:
A form contains controls, one or more of which can be other forms. A form that contains another form is known as a main form. A form contained by a main form is known as a subform. A subform itself...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.